public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug dynamic-link/26322] New: Libraries may fail to load if (p)read doesn't return all bytes requested
@ 2020-07-30 18:04 jasonwhite at fb dot com
  2020-08-03 18:00 ` [Bug dynamic-link/26322] " carlos at redhat dot com
  2020-08-03 18:00 ` carlos at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: jasonwhite at fb dot com @ 2020-07-30 18:04 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=26322

            Bug ID: 26322
           Summary: Libraries may fail to load if (p)read doesn't return
                    all bytes requested
           Product: glibc
           Version: 2.33
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: jasonwhite at fb dot com
  Target Milestone: ---

In `elf/dl-load.c` there is a call to pread[1]:

    if ((size_t) __pread64_nocancel (fd, (void *) phdr, maplength,
                                    ehdr->e_phoff) != maplength)
      {
      read_error:
          errval = errno;
          errstring = N_("cannot read file data");
          goto call_lose;
      }

However, there is no guarantee that pread will return all the bytes requested.
Thus, I believe the read should be wrapped in a loop to ensure it receives all
the bytes requested.

I found this issue while simulating a pathological kernel that only returns one
byte at a time for read calls using ptrace. I imagine this could also be
reproduced by writing a small FUSE file system that only returns a byte at a
time for reads.

[1]:
https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-load.c;h=c1bc8c26be1229fafc2a03afd9fb27edbcf8c3a8;hb=95c1056962a3f2297c94ce47f0eaf0c5b6563231#l1667

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug dynamic-link/26322] Libraries may fail to load if (p)read doesn't return all bytes requested
  2020-07-30 18:04 [Bug dynamic-link/26322] New: Libraries may fail to load if (p)read doesn't return all bytes requested jasonwhite at fb dot com
@ 2020-08-03 18:00 ` carlos at redhat dot com
  2020-08-03 18:00 ` carlos at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: carlos at redhat dot com @ 2020-08-03 18:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=26322

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #1 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Jason White from comment #0)
> I found this issue while simulating a pathological kernel that only returns
> one byte at a time for read calls using ptrace. I imagine this could also be
> reproduced by writing a small FUSE file system that only returns a byte at a
> time for reads.

Thanks for the report. There are probably a few places where we require the
read of a given length to succeed. You are right though, we should look into
this and either document the requirement or fix the issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug dynamic-link/26322] Libraries may fail to load if (p)read doesn't return all bytes requested
  2020-07-30 18:04 [Bug dynamic-link/26322] New: Libraries may fail to load if (p)read doesn't return all bytes requested jasonwhite at fb dot com
  2020-08-03 18:00 ` [Bug dynamic-link/26322] " carlos at redhat dot com
@ 2020-08-03 18:00 ` carlos at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: carlos at redhat dot com @ 2020-08-03 18:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=26322

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-08-03

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2020-08-03 18:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 18:04 [Bug dynamic-link/26322] New: Libraries may fail to load if (p)read doesn't return all bytes requested jasonwhite at fb dot com
2020-08-03 18:00 ` [Bug dynamic-link/26322] " carlos at redhat dot com
2020-08-03 18:00 ` carlos 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).