Skip to content

Commit 23c0dd1

Browse files
fixup! [libunwind] Replace process_vm_readv with pipe
1 parent fce7cba commit 23c0dd1

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,14 +2973,23 @@ bool UnwindCursor<A, R>::isReadableAddr(const pint_t addr) const {
29732973
// which is Copyright Abseil Authors (2017), and provided under
29742974
// the Apache License 2.0.
29752975

2976-
// We have to check that addr is nullptr (0) because sigprocmask allows that
2977-
// as an argument without failure.
2978-
if (addr == 0)
2979-
return false;
29802976
// Align to 8-bytes.
29812977
const auto alignedAddr = addr & ~pint_t{7};
29822978
const auto sigsetAddr = reinterpret_cast<sigset_t *>(alignedAddr);
2983-
[[maybe_unused]] int Result = sigprocmask(/*how=*/-1, sigsetAddr, nullptr);
2979+
// We have to check that addr is nullptr because sigprocmask allows that
2980+
// as an argument without failure.
2981+
if (!sigsetAddr)
2982+
return false;
2983+
2984+
// We MUST use the raw sigprocmask syscall here, as wrappers may try to
2985+
// access sigsetAddr which may cause a SIGSEGV. The raw syscall however is
2986+
// safe. Additionally, we need to pass the kernel_sigset_size, which is
2987+
// different from libc sizeof(sigset_t). Some archs have sigset_t
2988+
// defined as unsigned long, so let's use that.
2989+
const auto approxKernelSigsetSize = sizeof(unsigned long);
2990+
[[maybe_unused]] int Result =
2991+
syscall(SYS_rt_sigprocmask, /*how=*/~0, sigsetAddr, sigsetAddr,
2992+
approxKernelSigsetSize);
29842993
// Because our "how" is invalid, this syscall should always fail, and our
29852994
// errno should always be EINVAL or an EFAULT. EFAULT is not guaranteed
29862995
// by the POSIX standard, so this is (for now) Linux specific.

libunwind/test/bad_unwind_info.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
__attribute__((naked)) void bad_unwind_info() {
2727
#if defined(__aarch64__)
2828
__asm__("// not using 0 because unwinder was already resilient to that\n"
29-
"mov x8, #4\n"
29+
"mov x8, #12\n"
3030
"stp x30, x8, [sp, #-16]!\n"
3131
".cfi_def_cfa_offset 16\n"
3232
"// purposely use incorrect offset for x30\n"

0 commit comments

Comments
 (0)