public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: /, libsandbox/
Date: Mon, 13 Aug 2012 01:56:57 +0000 (UTC)	[thread overview]
Message-ID: <1344823003.53179a50a1a3e7a21e71cea6de46468deee87c69.vapier@gentoo> (raw)

commit:     53179a50a1a3e7a21e71cea6de46468deee87c69
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 13 01:56:05 2012 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Aug 13 01:56:43 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commit;h=53179a50

libsandbox: use process_vm_readv if available

Should speed up loading of strings from remote processes as we only have
to do (usually) one syscall to extract the whole string in one shot.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 configure.ac       |    2 ++
 headers.h          |    3 +++
 libsandbox/trace.c |   26 ++++++++++++++++++++++++++
 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);


             reply	other threads:[~2012-08-13  1:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-13  1:56 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-09 18:27 [gentoo-commits] proj/sandbox:master commit in: /, libsandbox/ Mike Gilbert
2025-01-08  2:12 [gentoo-commits] proj/sandbox:stable-2.x commit in: libsandbox/, / Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master commit in: /, libsandbox/ Mike Gilbert
2021-10-21 22:30 Mike Frysinger
2013-02-25  4:23 Mike Frysinger
2012-03-07  5:28 Mike Frysinger
2011-07-08 19:56 Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1344823003.53179a50a1a3e7a21e71cea6de46468deee87c69.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox