Re: [PATCH] mm/slub: Add slub_debug option to panic on memory corruption

Georgi Djakov
2021-03-09T18:13:05Z

Hi Christoph,

Thanks for the comments!

On 3/9/21 16:56, Christoph Lameter wrote:
> On Tue, 9 Mar 2021, Georgi Djakov wrote:
>
>> Being able to stop the system immediately when a memory corruption
>> is detected is crucial to finding the source of it. This is very
>> useful when the memory can be inspected with kdump or other tools.
>
> Hmmm.... ok.

The idea is to be able to collect data right after the corruption is
detected, otherwise more data might be corrupted and tracing becomes
more difficult.

>
>> static void restore_bytes(struct kmem_cache *s, char *message, u8 data,
>> void *from, void *to)
>> {
>> + if (slub_debug & SLAB_CORRUPTION_PANIC)
>> + panic("slab: object overwritten\n");
>> slab_fix(s, "Restoring 0x%p-0x%p=0x%x\n", from, to - 1, data);
>> memset(from, data, to - from);
>> }
>
> Why panic here? This should only be called late in the bug reporting when
> an error has already been printed.

This is called by both slab_pad_check() and check_bytes_and_report(), so it
seemed like a common place where i could put the panic(). I can move it to
the caller functions instead, if that's preferred.

Thanks,
Georgi