@@ -2970,8 +2970,7 @@ bool UnwindCursor<A, R>::getFunctionName(char *buf, size_t bufLen,
2970
2970
template <typename A, typename R>
2971
2971
bool UnwindCursor<A, R>::isReadableAddr(const pint_t addr) const {
2972
2972
// This code is heavily based on Abseil's 'address_is_readable.cc',
2973
- // which is Copyright Abseil Authors (2017), and provided under
2974
- // the Apache License 2.0.
2973
+ // which is Copyright Abseil Authors (2017).
2975
2974
2976
2975
// Align to 8-bytes.
2977
2976
const auto alignedAddr = addr & ~pint_t {7 };
@@ -2980,19 +2979,20 @@ bool UnwindCursor<A, R>::isReadableAddr(const pint_t addr) const {
2980
2979
// as an argument without failure.
2981
2980
if (!sigsetAddr)
2982
2981
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
2982
+ // We MUST use a raw syscall here, as wrappers may try to access
2983
+ // sigsetAddr which may cause a SIGSEGV. A raw syscall however is
2986
2984
// 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]] const int Result =
2991
- syscall (SYS_rt_sigprocmask, /* how= */ ~ 0 , sigsetAddr, sigsetAddr,
2992
- approxKernelSigsetSize) ;
2985
+ // different from libc sizeof(sigset_t). 8 seems to work for both 64bit and
2986
+ // 32bit archs .
2987
+ const auto approxKernelSigsetSize = 8 ;
2988
+ int Result = syscall (SYS_rt_sigprocmask, /* how= */ ~ 0 , sigsetAddr, nullptr ,
2989
+ approxKernelSigsetSize);
2990
+ ( void )Result ;
2993
2991
// Because our "how" is invalid, this syscall should always fail, and our
2994
2992
// errno should always be EINVAL or an EFAULT. EFAULT is not guaranteed
2995
- // by the POSIX standard, so this is (for now) Linux specific.
2993
+ // by the POSIX standard. Additionally, this relies on the Linux kernel
2994
+ // to check copy_from_user before checking if the "how" argument is
2995
+ // invalid.
2996
2996
assert (Result == -1 );
2997
2997
assert (errno == EFAULT || errno == EINVAL);
2998
2998
return errno != EFAULT;
0 commit comments