[libcxx-commits] [PATCH] D129856: [libunwind][SystemZ] Use process_vm_readv to avoid potential segfaults
    Ulrich Weigand via Phabricator via libcxx-commits 
    libcxx-commits at lists.llvm.org
       
    Mon Jul 18 07:59:28 PDT 2022
    
    
  
uweigand added a comment.
In D129856#3657718 <https://reviews.llvm.org/D129856#3657718>, @smeenai wrote:
> process_vm_readv was introduced in Linux 3.2; is it okay to use it unconditionally for you? (aarch64 support was only added in Linux 3.7, so we were guaranteed to have the syscall available for it.)
Well, while s390x Linux support long precedes Linux 3.2, it's still over 10 years old and all Linux distributions currently in support have a more recent kernel.  So I think it's fine to rely on in unconditionally.
================
Comment at: libunwind/src/UnwindCursor.hpp:2705
+  long bytesRead =
+      syscall(SYS_process_vm_readv, getpid(), &local_iov, 1, &remote_iov, 1, 0);
+  if (bytesRead == sizeof inst && (inst == 0x0a77 || inst == 0x0aad)) {
----------------
smeenai wrote:
> For aarch64, I went through `syscall` instead of the libc `process_vm_readv` wrapper because the latter wasn't guaranteed to be present even when the kernel supported the syscall (e.g. on Android 5). If you don't have that constraint, it'd be cleaner to just use the libc wrapper (assuming it's available on SystemZ).
Good point. All supported SystemZ Linux distributions have a recent enough glibc, so I've switched to the glibc wrapper.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129856/new/
https://reviews.llvm.org/D129856
    
    
More information about the libcxx-commits
mailing list