Bug 2297218 - la_objclose is called for ld.so in a private namespace without corresponding la_objopen call.
Summary: la_objclose is called for ld.so in a private namespace without corresponding ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 40
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Carlos O'Donell
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-07-10 20:57 UTC by Ben Woodard
Modified: 2025-05-20 19:24 UTC (History)
14 users (show)

Fixed In Version: glibc-2.40.9000-25.fc42
Clone Of:
Environment:
Last Closed: 2025-05-20 19:12:25 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
reproducer (1.11 KB, application/gzip)
2024-07-17 18:41 UTC, Ben Woodard
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Sourceware 31985 0 P2 NEW la_objopen not called when ld.so is imported into a private namespace. However, la_objclose is called with an unknown co... 2024-07-17 18:42:45 UTC

Description Ben Woodard 2024-07-10 20:57:35 UTC
When the application creates alternative namespaces with dlmopen, ld.so is loaded as a “fake” object into that namespace and la_objopen is not called, even though la_objclose is called on it later once the namespace is dlclose’d. Due to the limited argument set passed to la_objclose (only the uintptr_t cookie), the auditor is called with a cookie it has never set before and must decipher whether it points to its own structures or the default link_map.
There are two ways to look at it. 

You really aren't "opening" ld.so when it is imported into the new namepsace's link map. So I can understand why la_objopen() isn't being called. However, that being the case, I think that it shouldn't trigger la_objclose() either.

Or I can see how importing it into the new namespace is like opening it and we are just forgetting to call la_opbopen() in that case.

I think whichever way, the behavior should match.However, I think the most logical solution is to call la_objopen() from the code which imports ld.so into the private namespace.


Reproducible: Always

Steps to Reproduce:
1. tar xvzf missing-open-for-ldso.tar.gz 
2. cd missing-open-for-ldso/
3. make
Actual Results:  
$ make
gcc -o libauditor.so auditor.c -fPIC -shared
gcc -o main main.c -ldl
gcc -o libother.so libother.c -fPIC -shared

Success requires OK (not FAIL) at the end of each line:
LD_AUDIT=./libauditor.so ./main
  la_objopen('./main', lmid: 0), cookie 0x7f36d1172798 now = 2
  la_objopen('/lib64/ld-linux-x86-64.so.2', lmid: 0), cookie 0x7f36d1171f68 now = 2
  la_objopen('linux-vdso.so.1', lmid: 0), cookie 0x7f36d1172d78 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 0), cookie 0x7f36d110cf58 now = 2
Calling dlmopen(libother.so) [1]...
  la_activity('./libother.so', LA_ACT_ADD), cookie 0x178acb88 now = 1
  la_objopen('./libother.so', lmid: 2), cookie 0x178acb88 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 2), cookie 0x178ad148 now = 2
Calling dlmopen(libother.so) [2]...
  la_activity('./libother.so', LA_ACT_ADD), cookie 0x178ae0f8 now = 1
  la_objopen('./libother.so', lmid: 3), cookie 0x178ae0f8 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 3), cookie 0x178ae6b8 now = 2
Calling dlmopen(libother.so) [3]...
  la_activity('./libother.so', LA_ACT_ADD), cookie 0x178af668 now = 1
  la_objopen('./libother.so', lmid: 4), cookie 0x178af668 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 4), cookie 0x178afc28 now = 2
Calling dlclose([1])...
  la_objclose(0x178acb88)... OK.
  la_objclose(0x178ad148)... OK.
  la_objclose('/lib64/ld-linux-x86-64.so.2')... FAIL. (cookie unset)
Calling dlclose([2])...
  la_objclose(0x178ae0f8)... OK.
  la_objclose(0x178ae6b8)... OK.
  la_objclose('/lib64/ld-linux-x86-64.so.2')... FAIL. (cookie unset)
Calling dlclose([3])...
  la_objclose(0x178af668)... OK.
  la_objclose(0x178afc28)... OK.
  la_objclose('/lib64/ld-linux-x86-64.so.2')... FAIL. (cookie unset)
Exiting...
  la_objclose(0x7f36d1172798)... OK.
  la_objclose(0x7f36d110cf58)... OK.
  la_objclose(0x7f36d1171f68)... OK.


Expected Results:  
$ make
gcc -o libauditor.so auditor.c -fPIC -shared
gcc -o main main.c -ldl
gcc -o libother.so libother.c -fPIC -shared

Success requires OK (not FAIL) at the end of each line:
LD_AUDIT=./libauditor.so ./main
  la_objopen('./main', lmid: 0), cookie 0x7f36d1172798 now = 2
  la_objopen('/lib64/ld-linux-x86-64.so.2', lmid: 0), cookie 0x7f36d1171f68 now = 2
  la_objopen('linux-vdso.so.1', lmid: 0), cookie 0x7f36d1172d78 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 0), cookie 0x7f36d110cf58 now = 2
Calling dlmopen(libother.so) [1]...
  la_activity('./libother.so', LA_ACT_ADD), cookie 0x178acb88 now = 1
  la_objopen('./libother.so', lmid: 2), cookie 0x178acb88 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 2), cookie 0x178ad148 now = 2
Calling dlmopen(libother.so) [2]...
  la_activity('./libother.so', LA_ACT_ADD), cookie 0x178ae0f8 now = 1
  la_objopen('./libother.so', lmid: 3), cookie 0x178ae0f8 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 3), cookie 0x178ae6b8 now = 2
Calling dlmopen(libother.so) [3]...
  la_activity('./libother.so', LA_ACT_ADD), cookie 0x178af668 now = 1
  la_objopen('./libother.so', lmid: 4), cookie 0x178af668 now = 2
  la_objopen('/lib64/libc.so.6', lmid: 4), cookie 0x178afc28 now = 2
Calling dlclose([1])...
  la_objclose(0x178acb88)... OK.
  la_objclose(0x178ad148)... OK.
  la_objclose(0xSOMEADDRESS)... OK
Calling dlclose([2])...
  la_objclose(0x178ae0f8)... OK.
  la_objclose(0x178ae6b8)... OK.
  la_objclose(0xSOMEADDRESS)... OK
Calling dlclose([3])...
  la_objclose(0x178af668)... OK.
  la_objclose(0x178afc28)... OK.
  la_objclose(0xSOMEADDRESS)... OK
Exiting...
  la_objclose(0x7f36d1172798)... OK.
  la_objclose(0x7f36d110cf58)... OK.
  la_objclose(0x7f36d1171f68)... OK.

The point is the cookie used to call la_objclose() is known to the tool because the it was provided to the tool with an la_objopen() call.

Comment 1 Ben Woodard 2024-07-17 18:41:59 UTC
Created attachment 2039802 [details]
reproducer

to run the reproducer simply:

tar xvzf missing-open-for-ldso.tar.gz
cd missing-open-for-ldso
make

Comment 2 Carlos O'Donell 2024-09-06 13:49:41 UTC
Florian posted an upstream series to resolve the issue:
https://patchwork.sourceware.org/project/glibc/list/?series=38193

Still under review upstream.

Comment 3 Carlos O'Donell 2024-11-29 14:37:32 UTC
Review had changes-requested for one of the series patches.

Ongoing upstream work.

Comment 4 Aoife Moloney 2025-04-28 13:29:40 UTC
This message is a reminder that Fedora Linux 40 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 40 on 2025-05-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '40'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 40 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 5 Aoife Moloney 2025-05-20 19:12:25 UTC
Fedora Linux 40 entered end-of-life (EOL) status on 2025-05-13.

Fedora Linux 40 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 6 Florian Weimer 2025-05-20 19:24:27 UTC
Upstream commit:

commit 8f36b1469677afe37168f9af1b77402d7a70c673
Author: Florian Weimer <fweimer>
Date:   Fri Aug 9 15:31:18 2024 +0200

    elf: Signal la_objopen for the proxy link map in dlmopen (bug 31985)
    
    Previously, the ld.so link map was silently added to the namespace.
    This change produces an auditing event for it.
    
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella>

This and commits in the vicinity went into glibc-2.40.9000-25.fc42.


Note You need to log in before you can comment on or make changes to this bug.