================
@@ -2762,18 +2757,17 @@ int UnwindCursor<A, 
R>::stepThroughSigReturn(Registers_arm64 &) {
 template <typename A, typename R>
 bool UnwindCursor<A, R>::setInfoForSigReturn(Registers_riscv &) {
   const pint_t pc = static_cast<pint_t>(getReg(UNW_REG_IP));
-  uint32_t instructions[2];
-  struct iovec local_iov = {&instructions, sizeof instructions};
-  struct iovec remote_iov = {reinterpret_cast<void *>(pc), sizeof 
instructions};
-  long bytesRead =
-      syscall(SYS_process_vm_readv, getpid(), &local_iov, 1, &remote_iov, 1, 
0);
+  // The PC might contain an invalid address if the unwind info is bad, so
+  // directly accessing it could cause a SIGSEGV.
+  if (!isReadableAddr(pc) || !isReadableAddr(pc + 4))
----------------
MaskRay wrote:

It is unfortunate that we have to call `isReadableAddr` twice.

`linux/kernel/signal.c` `rt_sigprocmask` actually supports an unaligned 
address. We can remove the alignment code `const auto alignedAddr = addr & 
~pint_t{7};` and use one `isReadableAddr(pc)`

https://github.com/llvm/llvm-project/pull/74791
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to