Re: [kernel-hardening] Merge in PAX_MEMORY_SANITIZE work from grsec to linux-next

Kees Cook
2017-02-14T17:19:27Z

On Mon, Feb 13, 2017 at 7:01 PM, Kaiwan N Billimoria
<kaiwan@kaiwantech.com> wrote:
> Thanks for your response...
>>
>>
>>
>> > +config MEMORY_SANITIZE
>> > + bool "Enable memory sanitization features"
>> > + select SLUB_DEBUG
>> > + select PAGE_POISONING
>> > + select PAGE_POISONING_NO_SANITY if HIBERNATION
>> > + ---help---
>> > + This option enables ...
>>
>> Good start! Why the "if HIBERNATION" bit? It seems like sanity checks
>> are very expensive, so we'd not want it as part of this config?
>>
> Okay, I wasn't sure. So would it be (more) correct to retain the first two
> configs plus
> PAGE_POISONING_NO_SANITY (without the if)?

I think so, yes. We may need to tweak it in the future, but I think
that's the correct config for now.

>> > #if defined(CONFIG_SLUB_DEBUG_ON)
>> > +#if defined(CONFIG_MEMORY_SANITIZE)
>> > +/* With 'memory sanitize' On, slub_debug should be 'P' */
>> > +static int slub_debug = SLAB_POISON;
>> > +#else
>> > static int slub_debug = DEBUG_DEFAULT_FLAGS;
>> > +#endif /* CONFIG_MEMORY_SANITIZE */
>> > #else
>> > static int slub_debug;
>> > -#endif
>> > +#endif /* CONFIG_SLUB_DEBUG_ON */
>>
>> Could the definition of DEBUG_DEFAULT_FLAGS be adjusted instead of
>> doing the ifdefs here in the .c file? Or, perhaps do a slub_debug |=
>> SLAB_POISON in memory_sanitize_init()?
>>
> Yes, the latter sounds good but the init function is in mm/page_poison.c and
> the slub_debug var is a static in mm/slub.c . Any suggestions?

Perhaps add another early_init like you did the page_poison.c?

-Kees

--
Kees Cook
Pixel Security