Skip to content
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

nixos/hardened: option to use hardened-malloc systemwide #59955

Closed
wants to merge 1 commit into from

Conversation

joachifm
Copy link
Contributor

Not sure if this is the best way to go about this, but seems to "work", in that e.g., double free is detected & killed.

Not enabled by the hardened profile for now, needs a bit of testing.

Not enabled by the hardened profile for now, needs a bit of testing.
@joachifm
Copy link
Contributor Author

@GrahamcOfBorg test hardened

@risicle
Copy link
Contributor

risicle commented Apr 21, 2019

Neat 😁 - you might like to consider making this a setting that can generally cope with "alternative malloc implementations" rather than just a boolean - I'm looking at one or two more "hardened mallocs" which I'm considering adding.

@joachifm
Copy link
Contributor Author

My preference would be for the module to simply select "the best one", but then I don't know enough about the various hardened mallocs & their tradeoffs.

A general module could expose an option that lets you specify the path to the .so file or simply choose from one or more pre-defined alternatives ("graphene", "jemalloc", etc). Makes some sense to me, though there is decent potential for misconfiguration ...

I'll try to hack up something to better compare.

@joachifm
Copy link
Contributor Author

@risicle
Copy link
Contributor

risicle commented Apr 23, 2019

That looks great - there's of course this slight ... incongruity ... with the traditional way things work in nix-land - to minimize runtime link resolution. But these mallocs don't universally support linking directly into a libc and it's not practical to wrapProgram every binary in the system, so I can't think of anything better than a global LD_PRELOAD.

@joachifm
Copy link
Contributor Author

Yes, it's pretty awful ...

Besides wrappers, another alternative is to use /etc/ld-nix.so.preload but that is last in the preload order.

I feel like it should be possible to patch ld.so somehow specifically to support mandatory overrides for things like hardened allocators but that seems like a more ambitious undertaking & not sure if enough people care about this to make it worth it.

I'll probably polish the malloc module & submit a PR for it soonish.

@risicle
Copy link
Contributor

risicle commented Apr 24, 2019

Well, when it comes to "enough people caring" I'm always reminded how far behind the likes of OpenBSD we all are and how much we need to up our game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants