Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>,
	linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	Baoquan He <baoquan.he@linux.dev>,
	"David Hildenbrand (Arm)" <david@kernel.org>
Subject: Re: [PATCH v2] mm/vmalloc: Bail out if in softirq context
Date: Sun, 6 Dec 2026 15:11:32 +0100	[thread overview]
Message-ID: <axVtFF-iyNmPqRYA@milan> (raw)
In-Reply-To: <sashiko-outbox-246347@kernel.org>

On Wed, Dec 02, 2026 at 05:37:45PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] mm/vmalloc: WARN_ON_ONCE in __get_vm_area_node() on atomic
>   kvmalloc()
> --
> 
> commit b5a4024f17bff0a7c18243c940b773dd42c4d2f1
> Author: Uladzislau Rezki (Sony) <urezki@gmail.com>
> 
> mm/vmalloc: Bail out if in softirq context
> 
> This commit replaces the BUG_ON(in_nmi() || in_hardirq()) check in
> __get_vm_area_node() with a WARN_ON_ONCE() check that also rejects softirq
> and BH-disabled contexts and returns NULL.
> 
> > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > index a4c22c569b1de..fe5bdb4fde52b 100644
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -3258,7 +3258,12 @@ struct vm_struct *__get_vm_area_node(unsigned long size,
> >  	struct vm_struct *area;
> >  	unsigned long requested_size = size;
> >  
> > -	BUG_ON(in_nmi() || in_hardirq());
> > +	/*
> > +	 * Reject interrupt contexts, including BH-disabled task context.
> > +	 */
> > +	if (WARN_ON_ONCE(in_nmi() || in_hardirq() || softirq_count()))
> > +		return NULL;
> 
> [Severity: Medium]
> Can this trigger a WARN_ON_ONCE() splat on valid atomic kvmalloc() calls in
> softirq or BH-disabled context?
> 
No.

void *__kvmalloc_node_noprof(DECL_KMALLOC_PARAMS(size, b, token), unsigned long align,
			     gfp_t flags, int node)
{
	bool allow_block;
	void *ret;
	const struct slab_alloc_context ac = {
		.caller_addr = _RET_IP_,
		.orig_size = size,
		.alloc_flags = SLAB_ALLOC_DEFAULT,
	};

	/*
	 * It doesn't really make sense to fallback to vmalloc for sub page
	 * requests
	 */
	ret = __do_kmalloc_node(PASS_BUCKET_PARAM(b),
				kmalloc_gfp_adjust(flags, size),
				node, PASS_TOKEN_PARAM(token), &ac);
	if (ret || size <= PAGE_SIZE)
		return ret;

	/*
	 * vmalloc uses naked spin locks, so it must not be used if
	 * the caller already holds a spin lock that can be used in
	 * a soft or hard IRQ.  Use heuristics to detect this.
	 */
	if (irqs_disabled() || in_interrupt())
		return NULL;

--
Uladzislau Rezki


      reply	other threads:[~2026-12-06 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 17:37 [PATCH v2] mm/vmalloc: Bail out if in softirq context Uladzislau Rezki (Sony)
2026-12-02  2:31 ` Baoquan He
2026-12-06 14:24   ` Uladzislau Rezki
2026-12-02 17:37 ` sashiko-bot
2026-12-06 14:11   ` Uladzislau Rezki [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=axVtFF-iyNmPqRYA@milan \
    --to=urezki@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=david@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox