linux/drivers/net/ovpn
Ralf Lici c539cb30f9 ovpn: ensure packet delivery happens with BH disabled
ovpn injects decrypted packets into the netdev RX path through
ovpn_netdev_write() which invokes gro_cells_receive() and
dev_dstats_rx_add().

ovpn_netdev_write() is normally called in softirq context,
however, in case of TCP connections it may also be invoked
process context.

When this happens gro_cells_receive() will throw a warning:

  [  230.183747][   T12] WARNING: net/core/gro_cells.c:30 at gro_cells_receive+0x708/0xaa0, CPU#1: kworker/u16:0/12

and lockdep will also report a potential inconsistent lock state:

  WARNING: inconsistent lock state
  7.0.0-rc4+ #246 Tainted: G        W
  --------------------------------
  inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.

because attempts to acquire gro_cells->bh_lock by both
contexts may lead to a deadlock.

At the same time, dev_dstats_rx_add() does not expect to race
with a softirq (which may happen when invoked in process context),
because the latter may access its per-cpu state and corrupt
it.

Fix all this by invoking local_bh_disable/enable() around
gro_cells_receive() and dev_dstats_rx_add() to ensure that
bottom halves are always disabled before calling both of
them.

Fixes: 11851cbd60 ("ovpn: implement TCP transport")
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2026-05-05 00:31:06 +02:00
..
bind.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
bind.h ovpn: introduce the ovpn_peer object 2025-04-17 12:30:02 +02:00
crypto_aead.c ovpn: consolidate crypto allocations in one chunk 2026-03-17 11:09:20 +01:00
crypto_aead.h ovpn: implement key add/get/del/swap via netlink 2025-04-17 12:30:03 +02:00
crypto.c ovpn: kill key and notify userspace in case of IV exhaustion 2025-04-17 12:30:03 +02:00
crypto.h ovpn: kill key and notify userspace in case of IV exhaustion 2025-04-17 12:30:03 +02:00
io.c ovpn: ensure packet delivery happens with BH disabled 2026-05-05 00:31:06 +02:00
io.h ovpn: implement keepalive mechanism 2025-04-17 12:30:03 +02:00
main.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
main.h
Makefile ovpn: implement TCP transport 2025-04-17 12:30:03 +02:00
netlink-gen.c ovpn: add support for asymmetric peer IDs 2026-03-17 11:09:05 +01:00
netlink-gen.h ovpn: add support for asymmetric peer IDs 2026-03-17 11:09:05 +01:00
netlink.c ovpn: add support for asymmetric peer IDs 2026-03-17 11:09:05 +01:00
netlink.h ovpn: notify userspace on client float event 2026-03-17 11:08:55 +01:00
ovpnpriv.h ovpn: implement keepalive mechanism 2025-04-17 12:30:03 +02:00
peer.c drivers: net: drop ipv6_stub usage and use direct function calls 2026-03-29 11:21:23 -07:00
peer.h ovpn: add support for asymmetric peer IDs 2026-03-17 11:09:05 +01:00
pktid.c ovpn: pktid: use bitops.h API 2026-03-17 11:08:54 +01:00
pktid.h ovpn: pktid: use bitops.h API 2026-03-17 11:08:54 +01:00
proto.h ovpn: implement packet processing 2025-04-17 12:30:02 +02:00
skb.h ovpn: consolidate crypto allocations in one chunk 2026-03-17 11:09:20 +01:00
socket.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
socket.h ovpn: ensure sk is still valid during cleanup 2025-06-03 13:08:15 +02:00
stats.c ovpn: store tunnel and transport statistics 2025-04-17 12:30:02 +02:00
stats.h ovpn: store tunnel and transport statistics 2025-04-17 12:30:02 +02:00
tcp.c net: remove addr_len argument of recvmsg() handlers 2026-03-02 18:17:17 -08:00
tcp.h ovpn: ensure sk is still valid during cleanup 2025-06-03 13:08:15 +02:00
udp.c drivers: net: drop ipv6_stub usage and use direct function calls 2026-03-29 11:21:23 -07:00
udp.h ovpn: ensure sk is still valid during cleanup 2025-06-03 13:08:15 +02:00