Re: sched/debug: Dump end of stack when detected corrupted
From: Feng Tang
Date: Fri Sep 06 2024 - 07:48:11 EST
Hi Andrian,
On Fri, Sep 06, 2024 at 10:45:46AM +0200, John Paul Adrian Glaubitz wrote:
> Hi Feng,
>
> > - if (task_stack_end_corrupted(prev))
> > + if (task_stack_end_corrupted(prev)) {
> > + unsigned long *ptr = end_of_stack(prev);
> > +
> > + /* Dump 16 ulong words around the corruption point */
> > +#ifdef CONFIG_STACK_GROWSUP
> > + ptr -= 15;
> > +#endif
> > + print_hex_dump(KERN_ERR, "Corrupted Stack: ",
> > + DUMP_PREFIX_ADDRESS, 16, 1, ptr, 16 * sizeof(*ptr), 1);
> > +
>
> I would recommend determining the buffer element size with sizeof(unsigned long) for
> better readability and using "true" instead of "1" to set the value of the ascii
> parameter to print_hex_dump(), see [1]. Otherwise looks good to me.
Thanks for the review! Yes, I can make that change.
> Reviewed-by: John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>
>
> PS: Please CC me for a potential v3.
Sure.
Thanks,
Feng
> Thanks,
> Adrian
>
> > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/hexdump.c#n252