From 527225e492553b997d16adca7cc3bb472d5ef628 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Wed, 26 Jul 2006 21:46:39 -0600 Subject: [PATCH] [x86-64] Make a best effort at validating pointers before dereferencing them. Signed-off-by: Arun Sharma --- src/x86_64/Ginit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/x86_64/Ginit.c b/src/x86_64/Ginit.c index 5d2f2888..7bf01fb3 100644 --- a/src/x86_64/Ginit.c +++ b/src/x86_64/Ginit.c @@ -27,6 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "unwind_i.h" @@ -103,6 +104,9 @@ get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, return 0; } +#define PAGE_SIZE 4096 +#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) + static int access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, void *arg) @@ -114,6 +118,9 @@ access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, } else { + /* validate address */ + if (msync(PAGE_START(addr), 1, MS_SYNC) == -1) + return -1; *val = *(unw_word_t *) addr; Debug (16, "mem[%016lx] -> %lx\n", addr, *val); }