Skip to content

feat: apply hardened_malloc using LD_PRELOAD for user processes#1150

Merged
RoyalOughtness merged 4 commits intosecureblue:livefrom
HastD:hardened-malloc-override
Jun 26, 2025
Merged

feat: apply hardened_malloc using LD_PRELOAD for user processes#1150
RoyalOughtness merged 4 commits intosecureblue:livefrom
HastD:hardened-malloc-override

Conversation

@HastD
Copy link
Copy Markdown
Collaborator

@HastD HastD commented Jun 25, 2025

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 /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 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.

@HastD HastD requested a review from RoyalOughtness as a code owner June 25, 2025 20:23
HastD added 3 commits June 25, 2025 19:02
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.
@RoyalOughtness RoyalOughtness merged commit 5277620 into secureblue:live Jun 26, 2025
19 of 20 checks passed
@HastD HastD deleted the hardened-malloc-override branch June 26, 2025 17:26
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.
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.

4 participants