From: Catalin Marinas <catalin.marinas@arm.com>
To: Breno Leitao <leitao@debian.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, kuba@kernel.org, stable@kenrel.org,
kernel-team@meta.com
Subject: Re: [PATCH] mm/kmemleak: avoid deadlock by moving pr_warn() outside kmemleak_lock
Date: Mon, 4 Aug 2025 11:25:58 +0100 [thread overview]
Message-ID: <aJCKtmtus770t5LA@arm.com> (raw)
In-Reply-To: <20250731-kmemleak_lock-v1-1-728fd470198f@debian.org>
On Thu, Jul 31, 2025 at 02:57:18AM -0700, Breno Leitao wrote:
> When netpoll is enabled, calling pr_warn_once() while holding
> kmemleak_lock in mem_pool_alloc() can cause a deadlock due to lock
> inversion with the netconsole subsystem. This occurs because
> pr_warn_once() may trigger netpoll, which eventually leads to
> __alloc_skb() and back into kmemleak code, attempting to reacquire
> kmemleak_lock.
>
> This is the path for the deadlock.
>
> mem_pool_alloc()
> -> raw_spin_lock_irqsave(&kmemleak_lock, flags);
> -> pr_warn_once()
> -> netconsole subsystem
> -> netpoll
> -> __alloc_skb
> -> __create_object
> -> raw_spin_lock_irqsave(&kmemleak_lock, flags);
>
> Fix this by setting a flag and issuing the pr_warn_once() after
> kmemleak_lock is released.
>
> Reported-by: Jakub Kicinski <kuba@kernel.org>
> Fixes: c5665868183fec ("mm: kmemleak: use the memory pool for early allocations")
> Signed-off-by: Breno Leitao <leitao@debian.org>
I think Andrew already added this to mm-stable but, for the record:
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
prev parent reply other threads:[~2025-08-04 10:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-31 9:57 [PATCH] mm/kmemleak: avoid deadlock by moving pr_warn() outside kmemleak_lock Breno Leitao
2025-08-04 10:25 ` Catalin Marinas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aJCKtmtus770t5LA@arm.com \
--to=catalin.marinas@arm.com \
--cc=akpm@linux-foundation.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=stable@kenrel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.