aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--headers.h3
-rw-r--r--libsandbox/trace.c26
3 files changed, 31 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 65811dc..3529dcf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,7 @@ AC_CHECK_HEADERS_ONCE(m4_flatten([
sys/syscall.h
sys/time.h
sys/types.h
+ sys/uio.h
sys/user.h
sys/wait.h
asm/ptrace.h
@@ -168,6 +169,7 @@ AC_CHECK_FUNCS_ONCE(m4_flatten([
openat
openat64
pathconf
+ process_vm_readv
ptrace
realpath
remove
diff --git a/headers.h b/headers.h
index 512c85b..42b7c25 100644
--- a/headers.h
+++ b/headers.h
@@ -122,6 +122,9 @@
#ifdef HAVE_SYS_USER_H
# include <sys/user.h>
#endif
+#ifdef HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
diff --git a/libsandbox/trace.c b/libsandbox/trace.c
index ea769fd..c38ea12 100644
--- a/libsandbox/trace.c
+++ b/libsandbox/trace.c
@@ -90,6 +90,32 @@ static char *do_peekstr(unsigned long lptr)
if (lptr < sizeof(long))
return NULL;
+#ifdef HAVE_PROCESS_VM_READV
+ struct iovec liov, riov;
+
+ /* We can't cross remote page boundaries when using this :( */
+ l = 0x1000;
+ riov.iov_base = (void *)lptr;
+ len = lptr % l;
+ if (!len)
+ len = l;
+ liov.iov_base = ret = xmalloc(len);
+ riov.iov_len = liov.iov_len = len;
+
+ while (1) {
+ process_vm_readv(trace_pid, &liov, 1, &riov, 1, 0);
+
+ for (i = 0; i < liov.iov_len; ++i)
+ if (!((char *)liov.iov_base)[i])
+ return ret;
+ riov.iov_base += l;
+ riov.iov_len = liov.iov_len = l;
+ len += l;
+ ret = xrealloc(ret, len);
+ liov.iov_base = ret + len - l;
+ }
+#endif
+
l = 0;
len = 1024;
ret = xmalloc(len);