-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
environment.memoryAllocator no longer sets LD_PRELOAD. How can it now be disabled for specific commands? #65000
Comments
For example, I would run |
The hardened allocators also seem to break |
Setting I guess this comes down to whether we want the allocator to apply as broadly & robustly as possible or make it easy to override ad-hoc ... If users want hardened allocators but also want easy ad-hoc overrides I guess we can revert ld-so.preload to regain that ability, but I hadn't really envisioned this as a feature suitable for interactive systems. As it stands, it seems to me it's going to be difficult to provide both good ux for interactive systems and good coverage, at least from our end, given the number of bugs in apps & the allocators themselves (unclear to me which is at fault in the cases mentioned above). Ideally, these bugs would be reported & hopefully fixed. |
Another point in favor of ld-so.preload is that it works for setuid binaries. I really think it's the superior solution, despite being a little inconvenient. |
I thought programs were made to use the libc allocator by there being no other allocator preloaded. Is there a file containing the libc allocator somewhere whose path I can put in
Ah, I had wondered whether that might be the case. Could this be documented in the description of Also, it seems I hadn't tested thoroughly enough regarding the problem with Rust programs I mentioned: it does seem to be a problem caused (or, should I say, revealed) by the hardened allocator in general rather than by the specific method of preloading the hardened allocator, as Rust programs seem to segfault with both methods of preloading Scudo and run fine with the default libc allocator. (I would suspect that the reason they formerly worked fine is that, until Rust version 1.32, Rust programs used jemalloc rather than the system allocator — I thought I had tested since that change, but I guess not.) That Rust programs, which aren't necessarily interactive, are broken would seem to make this relevant even if the hardened allocators are intended only for non-interactive installations of NixOS, but—
—I agree that it would be best to fix the underlying bugs rather than hiding them. |
First of all, thank you for testing this :)
Yes. I've done a poor job communicating the potential breakage from the hardened profile, but that will be fixed in due time. To elaborate a little, the hardened defaults err on the side of breakage, with the expectation that admins will relax constraints that are unsuitable for their needs.
I was thinking of adding graphene-hardened-malloc upstream suggests running apps in mount namespace with empty ld-so.preload file (or without the hardened malloc .so). Maybe firejail or somesuch could be used to do this conveniently.
Uncovering bugs is the reason why this is default-on in the hardened profile on unstable. It likely won't make it into the upcoming release, there is just too much breakage, unfortunately. It would be good to have a tracking issue where we could collect known problems with debug output/whatever. |
Note that at least with Scudo you have the option of disabling parts of the hardening via environment variables, e.g. (e.g. I discovered yesterday that ffmpeg is broken by design and mixes memalign/realloc because "it works on all the systems we've tested". https://trac.ffmpeg.org/ticket/6403 . Everything using libsigc++ is also buggy.) |
Ah, I didn't know about that. |
Do you have an easy repro for the Rust case you're talking about? I've been testing alacritty recently and it's working fine. (Happy to take the off-topic elsewhere. If there is an easy repro case, we should just file a bug to upstream Rust.) |
@delroth:
—instead prints—
I doubt I can be very helpful debugging it, as I don't know how to use a debugger (I'm not a developer by trade). My own Rust |
Thank you for your contributions.
|
Issue description
Originally, the NixOS configuration option
environment.memoryAllocator.provider
worked by pointing the environment variableLD_PRELOAD
at the chosen memory allocator library — in my case,scudo
. I could disable this for a given commandfoo
by runningLD_PRELOAD= foo
at the command line.As of commit 44b6999, this has been changed no longer to use the environment variable
LD_PRELOAD
but rather the file/etc/ld-nix.so.preload
. Some searching of Google has not shown me any way to turn off this sort of preloading for a specific command. Is there such a way?cc @joachifm
Technical details
"x86_64-linux"
Linux 4.19.58-hardened, NixOS, 19.09pre185176.1036dc66416 (Loris)
yes
yes
nix-env (Nix) 2.2.2
"nixos-19.09pre185176.1036dc66416"
/nix/var/nix/profiles/per-user/root/channels/nixos
The text was updated successfully, but these errors were encountered: