92f446a
diff -rup a/elf/dl-load.c b/elf/dl-load.c
92f446a
--- a/elf/dl-load.c	2012-02-03 10:59:58.917870716 -0700
92f446a
+++ b/elf/dl-load.c	2012-02-03 11:01:01.796580644 -0700
92f446a
@@ -1130,6 +1130,16 @@ _dl_map_object_from_fd (const char *name
92f446a
 		= N_("ELF load command address/offset not properly aligned");
92f446a
 	      goto call_lose;
92f446a
 	    }
92f446a
+	  if (__builtin_expect ((ph->p_offset + ph->p_filesz > st.st_size), 0))
92f446a
+	    {
92f446a
+	      /* If the segment requires zeroing of part of its last
92f446a
+		 page, we'll crash when accessing the unmapped page.
92f446a
+		 There's still a possibility of a race, if the shared
92f446a
+		 object is truncated between the fxstat above and the
92f446a
+		 memset below.  */
92f446a
+	      errstring = N_("ELF load command past end of file");
92f446a
+	      goto call_lose;
92f446a
+	    }
92f446a
 
92f446a
 	  c = &loadcmds[nloadcmds++];
92f446a
 	  c->mapstart = ph->p_vaddr & ~(GLRO(dl_pagesize) - 1);
92f446a
Only in b/elf: dl-load.c.orig