Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: gro_cells: Reduce lock scope in gro_cell_poll

One GRO-cell device's NAPI callback can nest into the GRO-cell of
another device if the underlying device is also using GRO-cell.
This is the case for IPsec over vxlan.
These two GRO-cells are separate devices. From lockdep's point of view
it is the same because each device is sharing the same lock class and so
it reports a possible deadlock assuming one device is nesting into
itself.

Hold the bh_lock only while accessing gro_cell::napi_skbs in
gro_cell_poll(). This reduces the locking scope and avoids acquiring the
same lock class multiple times.

Fixes: 25718fdcbdd2 ("net: gro_cells: Use nested-BH locking for gro_cell")
Reported-by: Gal Pressman <gal@nvidia.com>
Closes: https://lore.kernel.org/all/66664116-edb8-48dc-ad72-d5223696dd19@nvidia.com/
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://patch.msgid.link/20251104153435.ty88xDQt@linutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Sebastian Andrzej Siewior and committed by
Jakub Kicinski
d917c217 b1d16f7c

+2 -2
+2 -2
net/core/gro_cells.c
··· 60 60 struct sk_buff *skb; 61 61 int work_done = 0; 62 62 63 - __local_lock_nested_bh(&cell->bh_lock); 64 63 while (work_done < budget) { 64 + __local_lock_nested_bh(&cell->bh_lock); 65 65 skb = __skb_dequeue(&cell->napi_skbs); 66 + __local_unlock_nested_bh(&cell->bh_lock); 66 67 if (!skb) 67 68 break; 68 69 napi_gro_receive(napi, skb); ··· 72 71 73 72 if (work_done < budget) 74 73 napi_complete_done(napi, work_done); 75 - __local_unlock_nested_bh(&cell->bh_lock); 76 74 return work_done; 77 75 } 78 76