Back in the October activity report, I detailed the rewritten kernel guarded heap, an alternative malloc implementation used to find memory bugs. Well, as of hrev59534 (yesterday), I’ve refactored the kernel to support being built with multiple heap implementations and choosing one at boot time, and so the guarded heap is now included in the nightly builds by default (though it’s not active by default, of course.)
So, now that it’s available for all users without needing to make a custom build, it’s time for anyone who can to test and see if we can uncover any bugs!
The procedure for testing is pretty simple. You can enable this either via the bootloader (tricky, but safe) or via the kernel settings file (easier, but less safe: if things break ,you’ll have to undo this using the bootloader advanced options menu).
First, the bootloader mechanism:
- Get to the bootloader menu, as normal (spam the spacebar, or hold SHIFT if you’re on legacy BIOS)
- Choose “Select debug options”, and then “Add advanced debug option”
- Enter the following:
kernel_malloc guarded
- Boot as normal.
Alternatively, the kernel settings file mechanism:
- Open the kernel settings file (
~/config/settings/kernel/drivers/kernel) - Add the line from step 3 above.
- Reboot.
- If your system won’t boot under this configuration, you’ll need to force the usage of the regular heap. Follow steps 1-2 from the bootloader mechanism, and then enter the option:
kernel_malloc slab
Once booted, you’ll need to edit the kernel settings file to remove the lines you’ve added.
You can confirm the kernel really is using the guarded heap by checking the syslog, it should contain the lines (early in the boot):
kernel malloc: using guarded_heap
guarded heap settings: R
After you’ve tested with just the basic guarded_heap, users on 64-bit can also test with the guarded heap in “memory reuse disabled” mode (which is even more effective at finding use-after-frees). To do that, you need two options, not just one:
kernel_malloc guarded
guarded_heap_options r
Any KDLs you encounter when running this way (well, except for “out of virtual memory” especially when running with memory reuse disabled for a long time, this is expected due to how much memory is wasted), please open ticket(s) with them as normal. (Or if you have existing KDL tickets that this changes the behavior of, upload the image to the existing ticket.) Any questions or comments, feel free to post or ask them here. Thanks!





