[libunwind] [llvm] [clang-tools-extra] [clang] [libunwind] Replace process_vm_readv with SYS_rt_sigprocmask (PR #74791)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 18 17:01:03 PST 2023


================
@@ -2822,13 +2816,11 @@ bool UnwindCursor<A, R>::setInfoForSigReturn(Registers_s390x &) {
   // onto the stack.
   const pint_t pc = static_cast<pint_t>(this->getReg(UNW_REG_IP));
   // The PC might contain an invalid address if the unwind info is bad, so
-  // directly accessing it could cause a segfault. Use process_vm_readv to
-  // read the memory safely instead.
-  uint16_t inst;
-  struct iovec local_iov = {&inst, sizeof inst};
-  struct iovec remote_iov = {reinterpret_cast<void *>(pc), sizeof inst};
-  long bytesRead = process_vm_readv(getpid(), &local_iov, 1, &remote_iov, 1, 0);
-  if (bytesRead == sizeof inst && (inst == 0x0a77 || inst == 0x0aad)) {
+  // directly accessing it could cause a SIGSEGV.
+  if (!isReadableAddr(pc) || !isReadableAddr(pc + 2))
----------------
MaskRay wrote:

Once call suffices as one rt_sigprocmask call checks 8 bytes.

https://github.com/llvm/llvm-project/pull/74791


More information about the cfe-commits mailing list