public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jasonwhite at fb dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/26322] New: Libraries may fail to load if (p)read doesn't return all bytes requested Date: Thu, 30 Jul 2020 18:04:21 +0000 [thread overview] Message-ID: <bug-26322-131@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2020-07-30 18:04 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-30 18:04 jasonwhite at fb dot com [this message] 2020-08-03 18:00 ` [Bug dynamic-link/26322] " carlos at redhat dot com 2020-08-03 18:00 ` carlos at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-26322-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).