public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elf: Check invalid hole in PT_LOAD segments [BZ #28838]
@ 2022-01-31 15:24 H.J. Lu
  2022-01-31 15:39 ` Florian Weimer
  2022-01-31 22:19 ` Michael Hudson-Doyle
  0 siblings, 2 replies; 5+ messages in thread
From: H.J. Lu @ 2022-01-31 15:24 UTC (permalink / raw)
  To: libc-alpha; +Cc: Florian Weimer, Carlos O'Donell, Michael Hudson-Doyle

commit 163f625cf9becbb82dfec63a29e566324129c0cd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 21 12:35:47 2021 -0800

    elf: Remove excessive p_align check on PT_LOAD segments [BZ #28688]

removed the p_align check against the page size.  It caused the loader
crash in shared objects with the invalid p_align.  Update _dl_map_segments
to detect invalid holes.  This fixes BZ #28838.
---
 elf/dl-map-segments.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h
index 172692b120..fd24cf5d01 100644
--- a/elf/dl-map-segments.h
+++ b/elf/dl-map-segments.h
@@ -113,6 +113,9 @@ _dl_map_segments (struct link_map *l, int fd,
              unallocated.  Then jump into the normal segment-mapping loop to
              handle the portion of the segment past the end of the file
              mapping.  */
+	  if (__glibc_unlikely (loadcmds[nloadcmds - 1].mapstart <
+				c->mapend))
+	    return N_("ELF load command address/offset not page-aligned");
           if (__glibc_unlikely
               (__mprotect ((caddr_t) (l->l_addr + c->mapend),
                            loadcmds[nloadcmds - 1].mapstart - c->mapend,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-31 22:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-31 15:24 [PATCH] elf: Check invalid hole in PT_LOAD segments [BZ #28838] H.J. Lu
2022-01-31 15:39 ` Florian Weimer
2022-01-31 15:59   ` H.J. Lu
2022-01-31 16:07   ` H.J. Lu
2022-01-31 22:19 ` Michael Hudson-Doyle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).