We can disable hardened_malloc per program by using bubblewrap (or any other namespacing program):
bwrap --dev-bind / / --tmpfs /usr/lib/libhardened_malloc.so program_name
This makes the /usr/lib/libhardened_malloc.so
directory an empty tmpfs without the hardened_malloc library so it isn’t preloaded:
ERROR: ld.so: object '/usr/lib/libhardened_malloc.so/libhardened_malloc.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
This can be verified with cat /proc/self/maps
. You’ll see /usr/lib/libhardened_malloc.so/libhardened_malloc.so
in the output without bubblewrap and it’ll be missing with bubblewrap.
So if we have any issues with programs, we can just use bubblewrap.