Skip to content

Avoid NULL pointer deref when libsandbox is in LD_PRELOAD#800

Merged
arkq merged 1 commit into
arkq:masterfrom
floppym:bug973030-libsandbox-dlopen
May 12, 2026
Merged

Avoid NULL pointer deref when libsandbox is in LD_PRELOAD#800
arkq merged 1 commit into
arkq:masterfrom
floppym:bug973030-libsandbox-dlopen

Conversation

@floppym
Copy link
Copy Markdown
Contributor

@floppym floppym commented May 9, 2026

libsandbox[1] calls dlopen() inside a constructor function. If this constructor happens to run before the init() function in libaloader.c, dlopen_orig will still be NULL and the program will crash with a segfault.

Avoid this by calling dlsym() inside the dlopen() wrapper itself when necessary.

[1] https://github.com/gentoo/sandbox

Bug: https://bugs.gentoo.org/973030

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.22%. Comparing base (2fa7fb0) to head (9f3e53d).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #800      +/-   ##
==========================================
+ Coverage   66.11%   66.22%   +0.11%     
==========================================
  Files          94       94              
  Lines       14494    14494              
  Branches     2534     2534              
==========================================
+ Hits         9582     9598      +16     
+ Misses       4912     4896      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@floppym
Copy link
Copy Markdown
Contributor Author

floppym commented May 11, 2026

I'm kind of baffled by the test failures; I cannot reproduce them.

I pushed a revert to see if this is some issue with the Github CI environment, but if you have a better idea of what is wrong please let me know.

@arkq
Copy link
Copy Markdown
Owner

arkq commented May 11, 2026

The failure might be just flakiness. I've re run failed tests. I had no time to check that earlier. Change looks OK, so I do not expect any issues with that PR.

@floppym floppym force-pushed the bug973030-libsandbox-dlopen branch from 9c19cc4 to 6133185 Compare May 11, 2026 15:35
If libsandbox[1] is in the LD_PRELOAD, it calls dlopen() inside a
constructor function. If this constructor happens to run before the
init() function in libaloader.c, dlopen_orig will still be NULL and
the program will crash with a segfault.

Avoid this by calling dlsym() inside the dlopen() wrapper itself when
necessary.

[1] https://github.com/gentoo/sandbox

Bug: https://bugs.gentoo.org/973030
@arkq arkq force-pushed the bug973030-libsandbox-dlopen branch from 6133185 to 9f3e53d Compare May 12, 2026 05:18
@arkq arkq merged commit 9f3e53d into arkq:master May 12, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants