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