diff options
authorMike Frysinger <vapier@gentoo.org>2015-09-20 18:25:33 -0400
committerMike Frysinger <vapier@gentoo.org>2015-09-20 18:25:33 -0400
commit0a9188fd0a812cb864819d37a6a7217a135b85f0 (patch)
tree24ebd8744cd6758e86a0e78c91448012c73da917 /localdecls.h
parentlibsandbox: fix process_vm_readv addresses/lengths (diff)
libsandbox: do not abort when the target uses bad pointers
If the target passes a bad pointer to the kernel, then trying to extract the data via ptrace will also throw an error. The tracing code should not abort though as there's no valid address to check, and kernel itself will return an error for us. Simply return and move on. URL: https://bugs.gentoo.org/560396 Reported-by: Jeroen Roovers <jer@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'localdecls.h')
1 files changed, 4 insertions, 0 deletions
diff --git a/localdecls.h b/localdecls.h
index 0e11fea..ecc5856 100644
--- a/localdecls.h
+++ b/localdecls.h
@@ -102,6 +102,10 @@ typedef struct user_regs_struct trace_regs;
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#define ALIGN_DOWN(base, size) ((base) & -(size))
+#define ALIGN_UP(base, size) ALIGN_DOWN((base) + (size) - 1, (size))
+#define PTR_ALIGN_DOWN(base, size) ((__typeof__(base))ALIGN_DOWN((uintptr_t)(base), (size)))
+#define PTR_ALIGN_UP(base, size) ((__typeof__(base))ALIGN_UP((uintptr_t)(base), (size)))
/* If the system is old and does not support *at funcs, then define
* it ourself. Shouldn't matter based on how we use it.