public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/13601] New: Fail to load dynamic libs when entire ELF header cannot be read in one syscall
@ 2012-01-18  4:15 tatannen at wisc dot edu
  2012-02-21  2:34 ` [Bug ld.so|libdl/13601] " jsm28 at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tatannen at wisc dot edu @ 2012-01-18  4:15 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13601

             Bug #: 13601
           Summary: Fail to load dynamic libs when entire ELF header
                    cannot be read in one syscall
           Product: glibc
           Version: 2.14
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: tatannen@wisc.edu
    Classification: Unclassified


As stated in the man pages, the read() system call may read/return less bytes
than requested, for a variety of well-documented reasons.
In elf/dl-load.c, function open_verify() attempts to read the entire elf header
(over 800 bytes on x86_84) in one invocation of the read system call, and if
all bytes are not read, the shared library will not load with a "file too
short" error. This could cause failures, for instance, loading over networked
file systems configured with a small (less than 800byte) MTU size.

In elf/dl-load.c the problem is here:
1714:      size_t maplength;
1715:
1716:      /* We successfully openened the file.  Now verify it is a file
1717:     we can use.  */
1718:      __set_errno (0);
1719:      fbp->len = __libc_read (fd, fbp->buf, sizeof (fbp->buf));
1720:
1721:      /* This is where the ELF header is loaded.  */
1722:      assert (sizeof (fbp->buf) > sizeof (ElfW(Ehdr)));
1723:      ehdr = (ElfW(Ehdr) *) fbp->buf;
1724:
1725:      /* Now run the tests.  */
1726:      if (__builtin_expect (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)), 0))
1727:    {
1728:      errval = errno;

On line 1719, if the read returns less than sizeof (ElfW(Ehdr)) as tested on
line 1726, the library load will fail.

The call to libc_read on line 1719 should be repeated while libc_read
returns a value greater than zero.  If you desire me to write/submit a patch,
I'd be happy to help out, just ask.

Thank you!

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2014-06-27 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-18  4:15 [Bug libc/13601] New: Fail to load dynamic libs when entire ELF header cannot be read in one syscall tatannen at wisc dot edu
2012-02-21  2:34 ` [Bug ld.so|libdl/13601] " jsm28 at gcc dot gnu.org
2012-10-20  3:31 ` [Bug dynamic-link/13601] " siddhesh at redhat dot com
2014-06-27 11:11 ` fweimer at redhat dot com

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).