public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "parky at outlook dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/30186] New: RTLD_DEEPBIND interacts badly with LD_PRELOAD Date: Wed, 01 Mar 2023 11:33:00 +0000 [thread overview] Message-ID: <bug-30186-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=30186 Bug ID: 30186 Summary: RTLD_DEEPBIND interacts badly with LD_PRELOAD Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: dynamic-link Assignee: unassigned at sourceware dot org Reporter: parky at outlook dot com Target Milestone: --- Created attachment 14726 --> https://sourceware.org/bugzilla/attachment.cgi?id=14726&action=edit Minimal example of issues with RTLD_DEEPBIND Loading a library with RTLD_DEEPBIND ignores LD_PRELOAD on any symbols in libc. # Minimal example I have constructed a minimal example to illustrate the problem (also attached to the issue): https://github.com/mjp41/deepbindexample This creates four things * `libdeepbind.so` - a library that exposes `expose`, which calls `free` with a bad value * `libpreload.so` - a library that provides a `free` that does nothing * `main_works` - an application that loads libdeepbind.so with just `RTLD_NOW` * `main_fails` - an application that loads libdeepbind.so with `RTLD_NOW | RTLD_DEEPBIND`. The two main applications just call `expose` on the loaded library `libdeepbind.so`. If we run ``` LD_PRELOAD=./libpreload.so ./main_works ``` then the program runs successfully: the bad `free` is handled by the preload and ignored. If we run ``` LD_PRELOAD=./libpreload.so ./main_fails ``` Then we get a segmentation fault from the libc allocator. This behaviour is not great for debugging and allocator replacement for any application using `RTLD_DEEPBIND`. # Concrete examples Previously, for allocator specific overrides, this was addressed with malloc hooks, e.g. https://github.com/jemalloc/jemalloc/commit/4bb09830133ffa8b27a95bc3727558007722c152 The jemalloc fix will fail silently now as the hooks have been removed in glibc, and jemalloc didn't include `malloc.h` to receive the deprecation warning. The current behaviour causes issues for Address Sanitizer: https://github.com/google/sanitizers/issues/611 and for applications such as PHP cannot override the allocator because of this behaviour: https://github.com/php/php-src/issues/10670 # Next steps As a possible solution, I wonder if there should be an explicit preload scope that is applied first to everything include RTLD_DEEPBIND libraries. However, I know very little about the loader, and cannot assess the compatibility issues that might cause. I am raising this issue as requested by Adhemerval Zanella in response to my Twitter thread on the topic https://twitter.com/ParkyMatthew/status/1630500641708683268 There is a previous bug raise on this issue: https://sourceware.org/bugzilla/show_bug.cgi?id=25533 That is marked as WONTFIX. I am not convinced a shared understanding was reached on the topic in that discussion. I hope my minimal example helps to make the problem clearer. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2023-03-01 11:33 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-01 11:33 parky at outlook dot com [this message] 2023-03-01 11:33 ` [Bug dynamic-link/30186] " parky at outlook dot com 2023-03-06 16:17 ` adhemerval.zanella at linaro dot org 2023-03-06 16:54 ` siddhesh at sourceware dot org 2023-03-08 20:41 ` parky at outlook dot com 2023-03-10 19:20 ` adhemerval.zanella at linaro dot org 2023-03-11 11:15 ` parky at outlook dot com 2023-03-13 11:52 ` parky at outlook dot com 2023-03-22 10:52 ` parky at outlook dot com 2023-03-22 11:39 ` adhemerval.zanella at linaro dot org 2023-03-22 11:48 ` parky at outlook dot com 2023-03-22 11:57 ` adhemerval.zanella at linaro dot org 2023-03-22 15:45 ` siddhesh at sourceware dot org 2023-03-22 16:25 ` adhemerval.zanella at linaro dot org 2023-03-22 16:25 ` adhemerval.zanella at linaro dot org 2023-03-22 16:57 ` siddhesh at sourceware dot org
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-30186-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).