public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ludo at gnu dot org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/26634] New: ld.so stats raw file names, bypassing the audit module
Date: Fri, 18 Sep 2020 21:44:20 +0000 [thread overview]
Message-ID: <bug-26634-131@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=26634
Bug ID: 26634
Summary: ld.so stats raw file names, bypassing the audit module
Product: glibc
Version: 2.31
Status: NEW
Severity: normal
Priority: P2
Component: dynamic-link
Assignee: unassigned at sourceware dot org
Reporter: ludo at gnu dot org
Target Milestone: ---
Created attachment 12850
--> https://sourceware.org/bugzilla/attachment.cgi?id=12850&action=edit
Audit module that can be used as a reproducer
Unless I'm mistaken, the loader can end up stat'ing raw directory names
(DT_RUNPATH entries) instead of stat'ing names returned by the audit module's
'la_objsearch'.
The attached audit module illustrates that. It's supposed to add "/PREFIX"
anytime 'name' has a leading slash (typically LA_SER_RUNPATH); yet, strace'ing
it shows that it calls 'stat' on the original file name, without "/PREFIX":
> $ strace -E LD_AUDIT=$PWD/audit.so -e stat expr --version
> [...]
> la_objsearch 4 '/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/haswell/libgmp.so.10' -> '/PREFIX/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/haswell/libgmp.so.10'
> stat("/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/haswell", 0x7ffe9f84c240) = -1 ENOENT (Dosiero aŭ dosierujo ne ekzistas)
> la_objsearch 4 '/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/x86_64/libgmp.so.10' -> '/PREFIX/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/x86_64/libgmp.so.10'
> stat("/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/x86_64", 0x7ffe9f84c240) = -1 ENOENT (Dosiero aŭ dosierujo ne ekzistas)
> la_objsearch 4 '/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/libgmp.so.10' -> '/PREFIX/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib/libgmp.so.10'
> stat("/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
> [...]
(Here the /gnu/store directory is from expr's DT_RUNPATH; notice that 'stat'
ignores "/PREFIX".)
The consequence is that some search path entries get marked as 'nonexisting'
even though they potentially shouldn't.
The culprit appears to be 'open_path' in 'dl-load.c':
fd = open_verify (buf, -1, fbp, loader, whatcode, mode,
found_other_class, false);
if (this_dir->status[cnt] == unknown)
{
if (fd != -1)
this_dir->status[cnt] = existing;
/* Do not update the directory information when loading
auditing code. We must try to disturb the program as
little as possible. */
else if (loader == NULL
|| GL(dl_ns)[loader->l_ns]._ns_loaded->l_auditing == 0)
{
/* We failed to open machine dependent library. Let's
test whether there is any directory at all. */
struct stat64 st;
buf[buflen - namelen - 1] = '\0';
if (__xstat64 (_STAT_VER, buf, &st) != 0
|| ! S_ISDIR (st.st_mode))
/* The directory does not exist or it is no directory. */
this_dir->status[cnt] = nonexisting;
else
this_dir->status[cnt] = existing;
}
}
Here 'buf' contains the original name. 'open_verify' is passed that original
name, calls the audit module's 'objsearch' function, and works on that.
However, the '__xstat64' call right below is passed 'buf'--i.e., the original
name.
Does that make sense?
(This stems from <https://issues.guix.gnu.org/43491>.)
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2020-09-18 21:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-18 21:44 ludo at gnu dot org [this message]
2020-09-18 23:55 ` [Bug dynamic-link/26634] " mark at klomp dot org
2020-09-24 9:54 ` ludo at gnu dot org
2020-09-24 10:29 ` fweimer at redhat dot com
2020-09-24 13:31 ` ludo at gnu dot org
2020-09-24 13:35 ` fweimer at redhat dot com
2020-09-24 13:50 ` ludo at gnu dot org
2020-09-24 13:56 ` fweimer at redhat dot com
2020-09-24 14:11 ` ludo at gnu dot org
2020-09-24 14:14 ` fweimer at redhat dot com
2020-09-24 14:37 ` ludo at gnu dot org
2020-09-24 14:39 ` fweimer at redhat dot com
2020-09-24 15:01 ` ludo at gnu dot org
2020-09-24 15:04 ` fweimer 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-26634-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: link
Be 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).