feat: apply hardened_malloc using LD_PRELOAD for user processes#1150
Merged
RoyalOughtness merged 4 commits intosecureblue:livefrom Jun 26, 2025
Merged
feat: apply hardened_malloc using LD_PRELOAD for user processes#1150RoyalOughtness merged 4 commits intosecureblue:livefrom
RoyalOughtness merged 4 commits intosecureblue:livefrom
Conversation
This reworks how hardened_malloc is applied: * For root-owned processes (including PID 1), `/etc/ld.so.preload` continues to be used to preload hardened_malloc; however, `/etc/ld.so.preload` is changed to only be readable by root. * `LD_PRELOAD=libhardened_malloc.so` is set in `/etc/environment`, which applies hardened_malloc to user processes. The impact is that hardened_malloc is still loaded by default for all processes, but non-root-owned processes can override it by unsetting `LD_PRELOAD`, rather than having to use user namespaces to prevent `ld.so.preload` from being read. This means that `ujust with-standard-malloc` no longer requires unconfined user namespace creation, and it has been made into a simple wrapper that unsets `LD_PRELOAD` for the passed command. The audit script has been modified to align with the new method of preloading hardened_malloc.
bc65888 to
a1b0590
Compare
RoyalOughtness
approved these changes
Jun 26, 2025
TheHooly
approved these changes
Jun 26, 2025
RKNF404
approved these changes
Jun 26, 2025
RoyalOughtness
pushed a commit
to RoyalOughtness/secureblue-dev
that referenced
this pull request
Aug 4, 2025
…reblue#1150) * feat: apply hardened_malloc using LD_PRELOAD for user processes This reworks how hardened_malloc is applied: * For root-owned processes (including PID 1), `/etc/ld.so.preload` continues to be used to preload hardened_malloc; however, `/etc/ld.so.preload` is changed to only be readable by root. * `LD_PRELOAD=libhardened_malloc.so` is set in `/etc/environment`, which applies hardened_malloc to user processes. The impact is that hardened_malloc is still loaded by default for all processes, but non-root-owned processes can override it by unsetting `LD_PRELOAD`, rather than having to use user namespaces to prevent `ld.so.preload` from being read. This means that `ujust with-standard-malloc` no longer requires unconfined user namespace creation, and it has been made into a simple wrapper that unsets `LD_PRELOAD` for the passed command. The audit script has been modified to align with the new method of preloading hardened_malloc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reworks how hardened_malloc is applied:
/etc/ld.so.preloadcontinues to be used to preload hardened_malloc; however,/etc/ld.so.preloadis changed to only be readable by root.LD_PRELOAD=libhardened_malloc.sois set in/usr/lib/environment.d/40-hardened_malloc.conf, which applies hardened_malloc to user processes.The impact is that hardened_malloc is still loaded by default for all processes, but non-root-owned processes can override it by unsetting
LD_PRELOAD, rather than having to use user namespaces to preventld.so.preloadfrom being read.This means that
ujust with-standard-mallocno longer requires unconfined user namespace creation, and it has been made into a simple wrapper that unsetsLD_PRELOADfor the passed command.The audit script has been modified to align with the new method of preloading hardened_malloc.