public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "woodard at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/31987] New: The name recorded in the link_map does not match what is returned by dlinfo(3)
Date: Wed, 17 Jul 2024 21:04:20 +0000	[thread overview]
Message-ID: <bug-31987-131@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 31987
           Summary: The name recorded in the link_map does not match what
                    is returned by dlinfo(3)
           Product: glibc
           Version: 2.39
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: woodard at redhat dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Created attachment 15631
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15631&action=edit
reproducer

link_map->l_name for main executable is an empty string and therefore does not
match the name returned by dlinfo(3) for the same object. Additionally
la_objopen() in an auditor is passed the same empty string. This really should
be populated with the name of the file being opened as it is in all other
cases. 

A second very closely related problem is in non-PIE executables the base
address found in the link_map is NULL while dlinfo(3) returns the correct
value. This should be set to be where the object is loaded.

Attached is a small reproducer simply:

tar xvzf inconsistent-objopen.tar.gz
cd inconsistent-objopen
make

The output will look something like:

ben@pun:~/Shared/Work/test/auditor-tests/tier2/inconsistent-objopen$ make

Success requires OK (not FAIL) at the end of output:
LD_AUDIT=./libauditor-vdso.so ./main-simple
  la_objopen('')
  la_objopen('/lib64/ld-linux-x86-64.so.2')
  la_objopen('linux-vdso.so.1')
    Seen vDSO from objopen!
  la_objopen('/lib64/libc.so.6')
la_preinit, scanning main link_map...
  l_name = ''
  l_name = 'linux-vdso.so.1'
    Seen vDSO in link map!
  l_name = '/lib64/libc.so.6'
  l_name = '/lib64/ld-linux-x86-64.so.2'
dladdr(vDSO) pathname matches link_map entry. OK.
dladdr(vDSO) base address matches link_map entry. OK.
vDSO notified via objopen. OK.

Success requires OK (not FAIL) at the end of output:
./main-dlinfo-pie
Name recorded in Dl_info:  './main-dlinfo-pie' at base 0x556ac1fbd000
Name recorded in link_map: '' at base 0x556ac1fbd000
Pathnames do not match. FAIL.
Base addresses match. OK.
./main-dlinfo-nopie
Name recorded in Dl_info:  './main-dlinfo-nopie' at base 0x400000
Name recorded in link_map: '' at base (nil)
Pathnames do not match. FAIL.
Base addresses do not match. FAIL.

The first problem is when the la_objopen() auditor function is called it is
passed an empty string for the object's name. This really should be populated
with the name of the file being opened as it is in almost all other cases. This
empty name is then what is stored in the link_map->l_name entry.  Subsequently,
when dlinfo(3) is called then it surprisingly is able to identify the object's
name. 

Then the base addresses do not match.

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

             reply	other threads:[~2024-07-17 21:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 21:04 woodard at redhat dot com [this message]
2024-08-08 13:10 ` [Bug libc/31987] " fweimer at redhat dot com
2024-08-08 13:11 ` fweimer at redhat dot com
2024-08-08 13:12 ` [Bug manual/31987] " 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-31987-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).