From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/
Date: Sun, 27 Sep 2015 06:13:26 +0000 (UTC) [thread overview]
Message-ID: <1442787001.9a927b63d0f76fb5edaf4abf43784419b944f21c.vapier@gentoo> (raw)
commit: 9a927b63d0f76fb5edaf4abf43784419b944f21c
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 20 22:10:01 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Sep 20 22:10:01 2015 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=9a927b63
libsandbox: fix process_vm_readv addresses/lengths
The current logic calculates the lengths/base addresses incorrectly
leading to some kernels/mappings to reject accesses. Make sure we
calculate the initial length properly, and then increment the base
by that value later on.
With those fixes in place, we can clean up the warning/exit paths.
URL: https://bugs.gentoo.org/560396
Reported-by: Jeroen Roovers <jer <AT> gentoo.org>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
libsandbox/trace.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/libsandbox/trace.c b/libsandbox/trace.c
index 47d2bdf..99ef8cd 100644
--- a/libsandbox/trace.c
+++ b/libsandbox/trace.c
@@ -93,10 +93,14 @@ static char *do_peekstr(unsigned long lptr)
#ifdef HAVE_PROCESS_VM_READV
struct iovec liov, riov;
- /* We can't cross remote page boundaries when using this :( */
+ /* We can't cross remote page boundaries when using this :(.
+ * The first call reads up to the edge of the page boundary since we
+ * have no (easy) way of knowing if the next page is valid. This is
+ * less effort than reading in the /proc/.../maps file and walking it.
+ */
l = 0x1000;
riov.iov_base = (void *)lptr;
- len = lptr % l;
+ len = l - (lptr % l);
if (!len)
len = l;
liov.iov_base = ret = xmalloc(len);
@@ -105,27 +109,23 @@ static char *do_peekstr(unsigned long lptr)
while (1) {
if (process_vm_readv(trace_pid, &liov, 1, &riov, 1, 0) == -1) {
int e = errno;
- if (e == ENOSYS)
+ if (e == ENOSYS) {
+ /* This can happen if run on older kernels but built with newer ones. */
+ break;
+ } else if (e == EFAULT) {
+ /* This can happen if the target process uses a bad pointer. #560396 */
break;
- sb_eqawarn("process_vm_readv(%i, %p{%p, %zu}, 1, %p{%p, %zu}, 1, 0) failed: %s\n",
+ }
+ sb_ebort("ISE:do_peekstr:process_vm_readv(%i, %p{%p, %#zx}, 1, %p{%p, %#zx}, 1, 0) failed: %s\n",
trace_pid,
&liov, liov.iov_base, liov.iov_len,
&riov, riov.iov_base, riov.iov_len,
strerror(e));
- if (e == EFAULT) {
- /* This sometimes happens, but it's not clear why.
- * Throw some extended debugging info before falling
- * back to the ptrace code. #560396
- */
- break;
- }
- sb_ebort("ISE:do_peekstr: process_vm_readv() hates us: %s\n",
- strerror(e));
}
if (memchr(liov.iov_base, '\0', liov.iov_len) != NULL)
return ret;
- riov.iov_base += l;
+ riov.iov_base += riov.iov_len;
riov.iov_len = liov.iov_len = l;
len += l;
ret = xrealloc(ret, len);
next reply other threads:[~2015-09-27 6:13 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-27 6:13 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
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 " Mike Gilbert
2024-12-22 19:19 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-12-22 19:19 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-12-22 19:02 Mike Gilbert
2024-12-22 19:02 Mike Gilbert
2024-12-22 3:49 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-12-22 3:41 Mike Gilbert
2024-11-04 19:15 Mike Gilbert
2024-01-27 18:05 Mike Gilbert
2024-01-22 21:41 Mike Gilbert
2023-08-08 15:27 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-04 0:26 Mike Gilbert
2023-08-01 14:14 Mike Gilbert
2021-11-03 16:40 Mike Frysinger
2021-11-03 16:40 Mike Frysinger
2021-11-03 6:59 Mike Frysinger
2021-10-31 23:54 Mike Frysinger
2021-10-28 9:56 Mike Frysinger
2021-10-28 7:14 Mike Frysinger
2021-10-28 3:41 Mike Frysinger
2021-10-23 22:19 Mike Frysinger
2021-10-23 6:10 Mike Frysinger
2021-10-23 6:10 Mike Frysinger
2021-10-22 4:20 Mike Frysinger
2021-10-22 4:15 Mike Frysinger
2021-10-21 20:37 Mike Frysinger
2021-10-21 20:37 Mike Frysinger
2021-10-21 1:51 Mike Frysinger
2021-10-18 22:04 Mike Frysinger
2021-09-07 15:35 Michał Górny
2021-04-02 11:22 Sergei Trofimovich
2021-03-15 18:08 Sergei Trofimovich
2019-06-25 6:42 Sergei Trofimovich
2018-12-02 15:22 Michał Górny
2018-07-19 11:50 Michał Górny
2018-02-18 21:32 Michał Górny
2017-10-03 16:42 Ian Stakenvicius
2017-10-03 16:39 Michał Górny
2016-03-30 5:22 Mike Frysinger
2016-03-29 12:24 Mike Frysinger
2015-12-19 18:10 Mike Frysinger
2015-12-19 18:10 Mike Frysinger
2015-12-19 7:29 Mike Frysinger
2015-09-27 6:13 Mike Frysinger
2015-09-20 8:15 Mike Frysinger
2015-09-20 8:15 Mike Frysinger
2015-09-20 8:15 Mike Frysinger
2015-09-20 8:15 Mike Frysinger
2015-09-11 7:53 Mike Frysinger
2013-02-25 4:12 Mike Frysinger
2013-02-25 4:08 Mike Frysinger
2012-06-23 23:12 Mike Frysinger
2012-06-23 22:40 Mike Frysinger
2012-06-23 21:21 Mike Frysinger
2012-03-07 5:28 Mike Frysinger
2011-07-08 19:53 Mike Frysinger
2011-07-08 19:53 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=1442787001.9a927b63d0f76fb5edaf4abf43784419b944f21c.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