Netdev List
 help / color / mirror / Atom feed
* [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock
       [not found]                 ` <auzOjphJ8DWpXwUy@milan>
@ 2026-12-01  8:52                   ` Herbert Xu
  2026-12-01  8:54                     ` netdev-bot+sinfo
  2026-12-01 17:01                     ` Linus Torvalds
  0 siblings, 2 replies; 5+ messages in thread
From: Herbert Xu @ 2026-12-01  8:52 UTC (permalink / raw)
  To: Uladzislau Rezki, netdev, Willem de Bruijn
  Cc: Linus Torvalds, Liam R. Howlett (Google), Davidlohr Bueso,
	Michal Hocko, Baoquan He, Alexander Potapenko, Andrey Ryabinin,
	Marco Elver, Michal Hocko, Linux Crypto Mailing List,
	Andrew Morton, Thomas Graf, linux-mm, linux-kernel, maple-tree,
	Lorenzo Stoakes, Chris Mason, Alice Ryhl, Andrew Ballance, stable,
	David Hildenbrand (Arm), Jordan Rife, Martin KaFai Lau

On Thu, Nov 05, 2026 at 07:44:30PM +0100, Uladzislau Rezki wrote:
> On Thu, Nov 05, 2026 at 04:51:39PM +0800, Herbert Xu wrote:
> > On Wed, Nov 04, 2026 at 12:11:24PM +0100, Uladzislau Rezki wrote:
>
> > > net/ipv4/udp.c:
> > >     err = bpf_iter_udp_realloc_batch(iter, batch_sks, GFP_NOWAIT);
> > 
> > This looks buggy in exactly the same way as rhashtable.  It's
> > called under spin_lock_bh, and the same lock can be taken on
> > the softirq path on another CPU.

Since we're not making any progress on resolving this within kvmalloc,
let's fix UDP to not call kvmalloc with GFP_NOWAIT.

---8<---
Even though kvmalloc was modified to support being called with
non-blocking flags such as GFP_NOWAIT and GFP_ATOMIC, it cannot
do so safely when used inside spin locks that may be taken from
soft or hard IRQs.  Doing so can lead to dead-lock because the
kvmalloc code takes naked spin locks without disabling soft or
hard IRQs.

Fix the UDP path to not call kvmalloc when BH spin locks are held.

Fixes: c6307674ed82 ("mm: kvmalloc: add non-blocking support for vmalloc")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index d784faf939c3..613ea92e95b1 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -3886,8 +3886,12 @@ static int bpf_iter_udp_realloc_batch(struct bpf_udp_iter_state *iter,
 {
 	union bpf_udp_iter_batch_item *new_batch;
 
-	new_batch = kvmalloc_objs(*new_batch, new_batch_sz,
-				  flags | __GFP_NOWARN);
+	if (flags != GFP_NOWAIT)
+		new_batch = kvmalloc_objs(*new_batch, new_batch_sz,
+					  flags | __GFP_NOWARN);
+	else
+		new_batch = kmalloc_objs(*new_batch, new_batch_sz,
+					 flags | __GFP_NOWARN);
 	if (!new_batch)
 		return -ENOMEM;
 
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock
  2026-12-01  8:52                   ` [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock Herbert Xu
@ 2026-12-01  8:54                     ` netdev-bot+sinfo
  2026-12-01  8:58                       ` Herbert Xu
  2026-12-01 17:01                     ` Linus Torvalds
  1 sibling, 1 reply; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-12-01  8:54 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Uladzislau Rezki, netdev, Willem de Bruijn, Linus Torvalds,
	Liam R. Howlett (Google), Davidlohr Bueso, Michal Hocko,
	Baoquan He, Alexander Potapenko, Andrey Ryabinin, Marco Elver,
	Michal Hocko, Linux Crypto Mailing List, Andrew Morton,
	Thomas Graf, linux-mm, linux-kernel, maple-tree, Lorenzo Stoakes,
	Chris Mason, Alice Ryhl, Andrew Ballance, stable,
	David Hildenbrand (Arm), Jordan Rife, Martin KaFai Lau

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock
  2026-12-01  8:54                     ` netdev-bot+sinfo
@ 2026-12-01  8:58                       ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2026-12-01  8:58 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: Uladzislau Rezki, netdev, Willem de Bruijn, Linus Torvalds,
	Liam R. Howlett (Google), Davidlohr Bueso, Michal Hocko,
	Baoquan He, Alexander Potapenko, Andrey Ryabinin, Marco Elver,
	Michal Hocko, Linux Crypto Mailing List, Andrew Morton,
	Thomas Graf, linux-mm, linux-kernel, maple-tree, Lorenzo Stoakes,
	Chris Mason, Alice Ryhl, Andrew Ballance, stable,
	David Hildenbrand (Arm), Jordan Rife, Martin KaFai Lau

On Tue, Dec 01, 2026 at 08:54:49AM +0000, netdev-bot+sinfo@kernel.org wrote:
> 
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
> 
>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by LLM and not proven at runtime). If it was triggered
>    please include the symptoms, like the stack trace or kernel messages.

The same issue was triggered on rhashtable.  The UDP bpf path has
exactly the same setup so it is vulnerable to the same issue.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock
  2026-12-01  8:52                   ` [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock Herbert Xu
  2026-12-01  8:54                     ` netdev-bot+sinfo
@ 2026-12-01 17:01                     ` Linus Torvalds
  2026-12-01 23:18                       ` Herbert Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2026-12-01 17:01 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Uladzislau Rezki, netdev, Willem de Bruijn,
	Liam R. Howlett (Google), Davidlohr Bueso, Michal Hocko,
	Baoquan He, Alexander Potapenko, Andrey Ryabinin, Marco Elver,
	Michal Hocko, Linux Crypto Mailing List, Andrew Morton,
	Thomas Graf, linux-mm, linux-kernel, maple-tree, Lorenzo Stoakes,
	Chris Mason, Alice Ryhl, Andrew Ballance, stable,
	David Hildenbrand (Arm), Jordan Rife, Martin KaFai Lau

On Tue, 1 Dec 2026 at 00:52, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> Fix the UDP path to not call kvmalloc when BH spin locks are held.

Bah. I don't love your previous patch, but it's better than this one.

So I applied the one to just not support kvmalloc in irq context.

              Linus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock
  2026-12-01 17:01                     ` Linus Torvalds
@ 2026-12-01 23:18                       ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2026-12-01 23:18 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Uladzislau Rezki, netdev, Willem de Bruijn,
	Liam R. Howlett (Google), Davidlohr Bueso, Michal Hocko,
	Baoquan He, Alexander Potapenko, Andrey Ryabinin, Marco Elver,
	Michal Hocko, Linux Crypto Mailing List, Andrew Morton,
	Thomas Graf, linux-mm, linux-kernel, maple-tree, Lorenzo Stoakes,
	Chris Mason, Alice Ryhl, Andrew Ballance, stable,
	David Hildenbrand (Arm), Jordan Rife, Martin KaFai Lau

On Tue, Dec 01, 2026 at 09:01:10AM -0800, Linus Torvalds wrote:
> 
> Bah. I don't love your previous patch, but it's better than this one.
> 
> So I applied the one to just not support kvmalloc in irq context.

Thanks Linus!

So just in case there is any confusion I am withdrawing this patch
to bpf UDP.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-01 23:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <auaFhOa5EBz4gJwK@gondor.apana.org.au>
     [not found] ` <xdzcyoou73blpfdlgy47i2ktrcsffnclerzojpgrxphid54gjc@nicdcvzqx447>
     [not found]   ` <auqtTjXhD8is-y9f@gondor.apana.org.au>
     [not found]     ` <CAHk-=wiE0KG+jkhmJWifXuAVivtB63WCWtdEpGAex7-T0SHd2g@mail.gmail.com>
     [not found]       ` <aurAxRpCwzeyXeVj@gondor.apana.org.au>
     [not found]         ` <CAHk-=wgPvbYRcKpQ8WTH-EYZRgMG0KSH+cZxY5-Hyf+X7JjWsw@mail.gmail.com>
     [not found]           ` <aurJZ81qnbiHH_P1@gondor.apana.org.au>
     [not found]             ` <ausS3LQNkdc6lBy3@milan>
     [not found]               ` <auxDm_YO4oACA_d2@gondor.apana.org.au>
     [not found]                 ` <auzOjphJ8DWpXwUy@milan>
2026-12-01  8:52                   ` [PATCH net] bpf: udp: Do not call kvmalloc while holding BH spin lock Herbert Xu
2026-12-01  8:54                     ` netdev-bot+sinfo
2026-12-01  8:58                       ` Herbert Xu
2026-12-01 17:01                     ` Linus Torvalds
2026-12-01 23:18                       ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox