Re: [PATCH] stackdepot: fix stack_depot_save_flags() in NMI context

From: Marco Elver
Date: Thu Nov 28 2024 - 04:14:45 EST


On Thu, 28 Nov 2024 at 02:25, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 22 Nov 2024 16:39:47 +0100 Marco Elver <elver@xxxxxxxxxx> wrote:
>
> > Per documentation, stack_depot_save_flags() was meant to be usable from
> > NMI context if STACK_DEPOT_FLAG_CAN_ALLOC is unset. However, it still
> > would try to take the pool_lock in an attempt to save a stack trace in
> > the current pool (if space is available).
> >
> > This could result in deadlock if an NMI is handled while pool_lock is
> > already held. To avoid deadlock, only try to take the lock in NMI
> > context and give up if unsuccessful.
>
> Is it possible to trigger this deadlock in current kernels, or is this
> a might-happen-in-the-future thing?

I can't find evidence this happens right now (at least with the quick
test I just ran), so it's more of a might happen if use of this API
broadens.

Thanks,
-- Marco