From 723017088be775e0921e476ea13b9e724a4e32ea Mon Sep 17 00:00:00 2001 From: kib Date: Mon, 12 Mar 2012 10:36:03 +0000 Subject: [PATCH 132/175] When iterating over the dso program headers, the object is not initialized yet, and object segments are not yet mapped. Only parse the notes that appear in the first page of the dso (as it should be anyway), and use the preloaded page content. Reported and tested by: stass MFC after: 20 days git-svn-id: http://svn.freebsd.org/base/head@232856 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f (cherry picked from commit 2717d1691daea92e00569e946f6673f481fdf21b) Signed-off-by: Xin Li --- libexec/rtld-elf/map_object.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index d240575..f142819 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -149,7 +149,10 @@ map_object(int fd, const char *path, const struct stat *sb) break; case PT_NOTE: - note_start = (Elf_Addr)obj->relocbase + phdr->p_offset; + if (phdr->p_offset > PAGE_SIZE || + phdr->p_offset + phdr->p_filesz > PAGE_SIZE) + break; + note_start = (Elf_Addr)(char *)hdr + phdr->p_offset; note_end = note_start + phdr->p_filesz; digest_notes(obj, note_start, note_end); break; -- 1.7.9.4