From: Uladzislau Rezki <urezki@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
Uladzislau Rezki <urezki@gmail.com>,
"Liam R. Howlett (Google)" <liam@infradead.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Michal Hocko <mhocko@suse.com>, Baoquan He <baoquan.he@linux.dev>,
Alexander Potapenko <glider@google.com>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Marco Elver <elver@google.com>, Michal Hocko <mhocko@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Graf <tgraf@suug.ch>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
maple-tree@lists.infradead.org, Lorenzo Stoakes <ljs@kernel.org>,
Chris Mason <mason@kernel.org>, Alice Ryhl <aliceryhl@google.com>,
Andrew Ballance <andrewjballance@gmail.com>,
stable@vger.kernel.org,
"David Hildenbrand (Arm)" <david@kernel.org>
Subject: Re: [PATCH] mm: kvmalloc: Bail if called with soft or hard IRQs disabled
Date: Sat, 14 Nov 2026 14:48:18 +0100 [thread overview]
Message-ID: <avhmosPSEJOFCvK_@milan> (raw)
In-Reply-To: <CAHk-=wg9baZ9EDhZr7ONxjuO65+vvWFo5E2hgxt+3rYo1vnhyA@mail.gmail.com>
On Fri, Nov 13, 2026 at 09:47:13AM -0800, Linus Torvalds wrote:
> On Fri, 13 Nov 2026 at 05:03, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> >
> > OK let's try this patch:
>
> I don't think this is wrong, but I do wonder if we should at least
> have *some* way to detect these cases and report them.
>
> Also, it turns out that in __get_vm_area_node(), we have
>
> BUG_ON(in_nmi() || in_hardirq());
>
> so this call sequence already has a *limited* test for this all. It's
> just that it explicitly allows softirqs, probably because it used that
> bogus BUG_ON() pattern, so it wasn't a debug aid, it was a "the
> machine is dead"
>
> I wish people would stop using BUG_ON() and friends. They are *only*
> valid for things where "something bad happened, I can't recover".
>
> That __get_vm_area_node() is not such a case. That function has a
> perfectly well-defined "what to do in case of errors". It already does
> it for lots of other cases: just return NULL.
>
> So using BUG_ON() is wrong, wrong, WRONG. Commit 04aa71da5f35
> ("mm/vmalloc: do not trigger BUG() on BH disabled context") was simply
> not the correct thing to do.
>
> The correct thing to do was to replace the buggy sh*t-for-brains
> BUG_ON() with the right sequence:
>
> - BUG_ON(in_interrupt());
> + if (WARN_ON_ONCE(in_interrupt())
> + return NULL;
>
I agree with this. The vmalloc() used to BUG_ON() if in_interrupt().
The easiest is to restore the old context restriction and replace
BUG_ON() with WARN_ON_ONCE() followed by returning NULL.
That would not stop machine but would show invalid callers.
If there are no objections i can send a patch.
--
Uladzislau Rezki
next prev parent reply other threads:[~2026-11-14 13:48 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 15:42 [PATCH 0/4] Lib fixes for 7.3 Liam R. Howlett (Google)
2026-10-28 15:42 ` [PATCH 1/4] maple_tree: Fix rcu reader NULL dereference after the tree is emptied Liam R. Howlett (Google)
2026-10-28 15:42 ` [PATCH 2/4] maple_tree: Test emptying tree while RCU reading Liam R. Howlett (Google)
2026-10-28 15:42 ` [PATCH 3/4] maple_tree: Update internal warning and bug_on code Liam R. Howlett (Google)
2026-10-28 17:54 ` Lorenzo Stoakes (ARM)
2026-10-28 18:37 ` Liam R. Howlett (Google)
2026-10-28 15:42 ` [PATCH 4/4] rhashtable: fix vmalloc() deadlock in atomic rehash Liam R. Howlett (Google)
2026-10-29 2:16 ` Herbert Xu
2026-10-29 10:08 ` Uladzislau Rezki
2026-10-29 14:53 ` Liam R. Howlett (Google)
2026-10-29 16:23 ` Michal Hocko
2026-10-30 4:48 ` Herbert Xu
2026-10-30 9:52 ` Uladzislau Rezki
2026-10-30 19:11 ` Matthew Wilcox
2026-11-02 11:18 ` Uladzislau Rezki
2026-10-31 0:56 ` Liam R. Howlett (Google)
2026-11-01 0:19 ` Herbert Xu
2026-11-03 1:49 ` Liam R. Howlett (Google)
2026-11-04 3:58 ` Herbert Xu
2026-11-04 4:28 ` Linus Torvalds
2026-11-04 5:21 ` Herbert Xu
2026-11-04 5:39 ` Linus Torvalds
2026-11-04 5:57 ` Herbert Xu
2026-11-04 11:11 ` Uladzislau Rezki
2026-11-05 8:51 ` Herbert Xu
2026-11-05 16:22 ` Linus Torvalds
2026-11-05 17:37 ` Uladzislau Rezki
2026-11-13 13:02 ` [PATCH] mm: kvmalloc: Bail if called with soft or hard IRQs disabled Herbert Xu
2026-11-13 17:47 ` Linus Torvalds
2026-11-14 0:35 ` Herbert Xu
2026-11-14 2:19 ` Linus Torvalds
2026-11-14 13:48 ` Uladzislau Rezki [this message]
2026-11-05 18:44 ` [PATCH 4/4] rhashtable: fix vmalloc() deadlock in atomic rehash Uladzislau Rezki
2026-11-05 21:02 ` Linus Torvalds
2026-11-06 5:49 ` Herbert Xu
2026-11-06 14:43 ` Uladzislau Rezki
2026-10-29 20:02 ` Matthew Wilcox
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=avhmosPSEJOFCvK_@milan \
--to=urezki@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=baoquan.he@linux.dev \
--cc=dave@stgolabs.net \
--cc=david@kernel.org \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=maple-tree@lists.infradead.org \
--cc=mason@kernel.org \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=ryabinin.a.a@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tgraf@suug.ch \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox