netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive()
@ 2025-10-20 16:11 Eric Dumazet
  2025-10-20 23:53 ` David Ahern
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-10-20 16:11 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Kuniyuki Iwashima, netdev, eric.dumazet,
	Eric Dumazet, syzbot+f9651b9a8212e1c8906f,
	Sebastian Andrzej Siewior

syzbot found that the local_unlock_nested_bh() call was
missing in some cases.

WARNING: possible recursive locking detected
syzkaller #0 Not tainted
--------------------------------------------
syz.2.329/7421 is trying to acquire lock:
 ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:44 [inline]
 ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: gro_cells_receive+0x404/0x790 net/core/gro_cells.c:30

but task is already holding lock:
 ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:44 [inline]
 ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: gro_cells_receive+0x404/0x790 net/core/gro_cells.c:30

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock((&cell->bh_lock));
  lock((&cell->bh_lock));

 *** DEADLOCK ***

Given the introduction of @have_bh_lock variable, it seems the author
intent was to have the local_unlock_nested_bh() after the @unlock label.

Fixes: 25718fdcbdd2 ("net: gro_cells: Use nested-BH locking for gro_cell")
Reported-by: syzbot+f9651b9a8212e1c8906f@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/68f65eb9.a70a0220.205af.0034.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 net/core/gro_cells.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/core/gro_cells.c b/net/core/gro_cells.c
index b43911562f4d10aa3d05c60f343ff89c5d9ed58d..fd57b845de333ff0e397eeb95aa67926d4e4a730 100644
--- a/net/core/gro_cells.c
+++ b/net/core/gro_cells.c
@@ -43,12 +43,11 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
 	if (skb_queue_len(&cell->napi_skbs) == 1)
 		napi_schedule(&cell->napi);
 
-	if (have_bh_lock)
-		local_unlock_nested_bh(&gcells->cells->bh_lock);
-
 	res = NET_RX_SUCCESS;
 
 unlock:
+	if (have_bh_lock)
+		local_unlock_nested_bh(&gcells->cells->bh_lock);
 	rcu_read_unlock();
 	return res;
 }
-- 
2.51.0.858.gf9c4a03a3a-goog


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

* Re: [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive()
  2025-10-20 16:11 [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive() Eric Dumazet
@ 2025-10-20 23:53 ` David Ahern
  2025-10-22  0:50 ` patchwork-bot+netdevbpf
  2025-10-24 13:47 ` Sebastian Andrzej Siewior
  2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2025-10-20 23:53 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Kuniyuki Iwashima, netdev, eric.dumazet,
	syzbot+f9651b9a8212e1c8906f, Sebastian Andrzej Siewior

On 10/20/25 10:11 AM, Eric Dumazet wrote:
> syzbot found that the local_unlock_nested_bh() call was
> missing in some cases.
> 
> WARNING: possible recursive locking detected
> syzkaller #0 Not tainted
> --------------------------------------------
> syz.2.329/7421 is trying to acquire lock:
>  ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:44 [inline]
>  ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: gro_cells_receive+0x404/0x790 net/core/gro_cells.c:30
> 
> but task is already holding lock:
>  ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:44 [inline]
>  ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: gro_cells_receive+0x404/0x790 net/core/gro_cells.c:30
> 
> other info that might help us debug this:
>  Possible unsafe locking scenario:
> 
>        CPU0
>        ----
>   lock((&cell->bh_lock));
>   lock((&cell->bh_lock));
> 
>  *** DEADLOCK ***
> 
> Given the introduction of @have_bh_lock variable, it seems the author
> intent was to have the local_unlock_nested_bh() after the @unlock label.
> 
> Fixes: 25718fdcbdd2 ("net: gro_cells: Use nested-BH locking for gro_cell")
> Reported-by: syzbot+f9651b9a8212e1c8906f@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/68f65eb9.a70a0220.205af.0034.GAE@google.com/T/#u
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  net/core/gro_cells.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>



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

* Re: [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive()
  2025-10-20 16:11 [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive() Eric Dumazet
  2025-10-20 23:53 ` David Ahern
@ 2025-10-22  0:50 ` patchwork-bot+netdevbpf
  2025-10-24 13:47 ` Sebastian Andrzej Siewior
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-22  0:50 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, horms, kuniyu, netdev, eric.dumazet,
	syzbot+f9651b9a8212e1c8906f, bigeasy

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 20 Oct 2025 16:11:14 +0000 you wrote:
> syzbot found that the local_unlock_nested_bh() call was
> missing in some cases.
> 
> WARNING: possible recursive locking detected
> syzkaller #0 Not tainted
> --------------------------------------------
> syz.2.329/7421 is trying to acquire lock:
>  ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:44 [inline]
>  ffffe8ffffd48888 ((&cell->bh_lock)){+...}-{3:3}, at: gro_cells_receive+0x404/0x790 net/core/gro_cells.c:30
> 
> [...]

Here is the summary with links:
  - [net] net: gro_cells: fix lock imbalance in gro_cells_receive()
    https://git.kernel.org/netdev/net/c/c5394b8b7a92

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive()
  2025-10-20 16:11 [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive() Eric Dumazet
  2025-10-20 23:53 ` David Ahern
  2025-10-22  0:50 ` patchwork-bot+netdevbpf
@ 2025-10-24 13:47 ` Sebastian Andrzej Siewior
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-10-24 13:47 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Kuniyuki Iwashima, netdev, eric.dumazet,
	syzbot+f9651b9a8212e1c8906f

On 2025-10-20 16:11:14 [+0000], Eric Dumazet wrote:
> syzbot found that the local_unlock_nested_bh() call was
> missing in some cases.

Thank you Eric.

> Given the introduction of @have_bh_lock variable, it seems the author
> intent was to have the local_unlock_nested_bh() after the @unlock label.

Indeed that was the intention. It is even noted in the diffstat that
this the reason the variable.

Sebastian

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

end of thread, other threads:[~2025-10-24 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 16:11 [PATCH net] net: gro_cells: fix lock imbalance in gro_cells_receive() Eric Dumazet
2025-10-20 23:53 ` David Ahern
2025-10-22  0:50 ` patchwork-bot+netdevbpf
2025-10-24 13:47 ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).