Valgrind: r16334 - /trunk/coregrind/m_syswrap/syswrap-linux.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Valgrind: r16334 - /trunk/coregrind/m_syswrap/syswrap-linux.c

svn-2
Author: iraisr
Date: Fri May  5 14:20:15 2017
New Revision: 16334

Log:
Fix Valgrind internal error when dereferencing memory supplied by a client
in ptrace(getregset) and ptrace(setregset) syscall wrappers.
n-i-bz

Modified:
    trunk/coregrind/m_syswrap/syswrap-linux.c

Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c Fri May  5 14:20:15 2017
@@ -11190,12 +11190,12 @@
 {
    struct vki_iovec *iov = (struct vki_iovec *) arg4;
 
-   PRE_MEM_READ("ptrace(getregset iovec->iov_base)",
- (unsigned long) &iov->iov_base, sizeof(iov->iov_base));
-   PRE_MEM_READ("ptrace(getregset iovec->iov_len)",
- (unsigned long) &iov->iov_len, sizeof(iov->iov_len));
-   PRE_MEM_WRITE("ptrace(getregset *(iovec->iov_base))",
- (unsigned long) iov->iov_base, iov->iov_len);
+   PRE_FIELD_READ("ptrace(getregset iovec->iov_base)", iov->iov_base);
+   PRE_FIELD_READ("ptrace(getregset iovec->iov_len)", iov->iov_len);
+   if (ML_(safe_to_deref)(iov, sizeof(struct vki_iovec))) {
+      PRE_MEM_WRITE("ptrace(getregset *(iovec->iov_base))",
+                    (Addr) iov->iov_base, iov->iov_len);
+   }
 }
 
 void
@@ -11203,12 +11203,12 @@
 {
    struct vki_iovec *iov = (struct vki_iovec *) arg4;
 
-   PRE_MEM_READ("ptrace(setregset iovec->iov_base)",
- (unsigned long) &iov->iov_base, sizeof(iov->iov_base));
-   PRE_MEM_READ("ptrace(setregset iovec->iov_len)",
- (unsigned long) &iov->iov_len, sizeof(iov->iov_len));
-   PRE_MEM_READ("ptrace(setregset *(iovec->iov_base))",
- (unsigned long) iov->iov_base, iov->iov_len);
+   PRE_FIELD_READ("ptrace(setregset iovec->iov_base)", iov->iov_base);
+   PRE_FIELD_READ("ptrace(setregset iovec->iov_len)", iov->iov_len);
+   if (ML_(safe_to_deref)(iov, sizeof(struct vki_iovec))) {
+      PRE_MEM_READ("ptrace(setregset *(iovec->iov_base))",
+                   (Addr) iov->iov_base, iov->iov_len);
+   }
 }
 
 void


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers