Skip to content

fix: Use the correct syscall for process_vm_readv - #4

Merged
Swatinem merged 4 commits into
masterfrom
fix/correct-vmread
Jun 29, 2021
Merged

Swatinem merged 4 commits into
masterfrom
fix/correct-vmread

Conversation

@Swatinem

Copy link
Copy Markdown

It seems that some code added in ivanarh@af11b0c#diff-3110c28650da71aad0da90c7564871442ba3651cdb2e3eed5f14b85007568c97R295 and 453f55d#diff-3110c28650da71aad0da90c7564871442ba3651cdb2e3eed5f14b85007568c97R27 was wrong and the calls to process_vm_readv were incorrect, and the code retried using a straight memcpy, which possibly lead to some segfaults.

The new changes use the exported function directly on newer Android releases, and create a functioning wrapper for older Android versions.

@Swatinem

Copy link
Copy Markdown
Author

The needed functions were added in https://android.googlesource.com/platform/bionic/+/be57a40 which is Android API 23 (M)

@Swatinem
Swatinem merged commit a4c27d4 into master Jun 29, 2021
@Swatinem
Swatinem deleted the fix/correct-vmread branch June 29, 2021 07:25
jpnurmi added a commit that referenced this pull request Oct 29, 2026
`strip_pac()` only strips with a mask, and nothing sets one. The
`__bionic_clear_pac_bits()` fallback was compiled out because it is
not in the NDK, so a signed return address ended the unwind.

Strip with `xpaclri` like bionic does, spelled as `hint #7` for
assemblers without Armv8.3-A support. It is a NOP on older CPUs.

Pixel 8 Pro (Tensor G3, Android 17), `abort()` through two
`-mbranch-protection=pac-ret` functions, unwound from a SIGABRT
handler like sentry-native's inproc backend.

Before:
    #00 pc 000000000007fdc0  .../libc.so (abort+160)
    #1 pc 006e8cdf7ce216d0  <unknown>

After:
    #00 pc 000000000007fdc0  .../libc.so (abort+160)
    #1 pc 000000000002867c  .../pac_test (pac_crash()+12)
    #2 pc 000000000002868c  .../pac_test (pac_caller()+12)
    #3 pc 0000000000028708  .../pac_test (main+120)
    #4 pc 000000000007183c  .../libc.so (__libc_init+124)

Ref: getsentry/sentry-native#2258
jpnurmi added a commit that referenced this pull request Oct 29, 2026
`strip_pac()` only strips with a mask, and nothing sets one. The
`__bionic_clear_pac_bits()` fallback was compiled out because it is
not in the NDK, so a signed return address ended the unwind.

Strip with `xpaclri` like bionic does, spelled as `hint #7` for
assemblers without Armv8.3-A support. It is a NOP on older CPUs.

Pixel 8 Pro (Tensor G3, Android 17), `abort()` through two
`-mbranch-protection=pac-ret` functions, unwound from a SIGABRT
handler like sentry-native's inproc backend.

Before:
    #00 pc 000000000007fdc0  .../libc.so (abort+160)
    #1 pc 006e8cdf7ce216d0  <unknown>

After:
    #00 pc 000000000007fdc0  .../libc.so (abort+160)
    #1 pc 000000000002867c  .../pac_test (pac_crash()+12)
    #2 pc 000000000002868c  .../pac_test (pac_caller()+12)
    #3 pc 0000000000028708  .../pac_test (main+120)
    #4 pc 000000000007183c  .../libc.so (__libc_init+124)

Ref: getsentry/sentry-native#2258
jpnurmi added a commit that referenced this pull request Oct 30, 2026
* fix(arm64): unwind past PAC-signed return addresses

`strip_pac()` only strips with a mask, and nothing sets one. The
`__bionic_clear_pac_bits()` fallback was compiled out because it is
not in the NDK, so a signed return address ended the unwind.

Strip with `xpaclri` like bionic does, spelled as `hint #7` for
assemblers without Armv8.3-A support. It is a NOP on older CPUs.

Pixel 8 Pro (Tensor G3, Android 17), `abort()` through two
`-mbranch-protection=pac-ret` functions, unwound from a SIGABRT
handler like sentry-native's inproc backend.

Before:
    #00 pc 000000000007fdc0  .../libc.so (abort+160)
    #1 pc 006e8cdf7ce216d0  <unknown>

After:
    #00 pc 000000000007fdc0  .../libc.so (abort+160)
    #1 pc 000000000002867c  .../pac_test (pac_crash()+12)
    #2 pc 000000000002868c  .../pac_test (pac_caller()+12)
    #3 pc 0000000000028708  .../pac_test (main+120)
    #4 pc 000000000007183c  .../libc.so (__libc_init+124)

Ref: getsentry/sentry-native#2258

* link to arm developer docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant