linux/net/openvswitch
Yuqi Xu 403f96c32c openvswitch: Fix CT limit teardown use-after-free
Packet processing uses CT limit state under RCU, while netns teardown
frees that state under ovs_mutex. The CT limit pointer was neither removed
from readers nor protected by a grace period, allowing packet processing to
dereference the freed state.

An unprivileged user can trigger this bug from a user and network
namespace, causing a slab-use-after-free in ovs_ct_execute() when the
netns is torn down.

Publish the CT limit pointer through RCU, remove it before teardown, and
wait for readers before freeing its contents. Keep ovs_mutex around
individual CT limit updates, and use the RCU read-side lock while GET
traverses the RCU-protected limit lists.

Netns teardown detaches the RCU-protected CT limit state in the pernet
.pre_exit callback while holding ovs_mutex.  The pernet core guarantees an
RCU grace period between the .pre_exit and .exit callbacks, so the .exit
callback completes the teardown without adding any extra synchronization.

The netlink command handlers do not need NULL checks because the userspace
netlink socket holds an active reference to its network namespace while a
request is processed. The per-netns exit path therefore cannot run
concurrently with SET, DEL, or GET for that socket's namespace.

Fixes: 11efd5cb04 ("openvswitch: Support conntrack zone limit")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Link: https://lore.kernel.org/all/cover.1784711445.git.xuyuqiabc@gmail.com
Co-developed-by: Nan Li <tonanli66@gmail.com>
Signed-off-by: Nan Li <tonanli66@gmail.com>
Signed-off-by: Yuqi Xu <xuyuqiabc@gmail.com>
Reviewed-by: Ren Wei <enjou1224z@gmail.com>
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
Link: https://patch.msgid.link/288fbd5459d92b9dd0dcc6faf625f04819161ff3.1787280296.git.xuyuqiabc@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-24 11:38:09 -07:00
..
actions.c net: openvswitch: fix skb leak on flow key update failure during ct 2026-07-29 17:42:33 -07:00
conntrack.c openvswitch: Fix CT limit teardown use-after-free 2026-08-24 11:38:09 -07:00
conntrack.h openvswitch: Fix CT limit teardown use-after-free 2026-08-24 11:38:09 -07:00
datapath.c openvswitch: Fix CT limit teardown use-after-free 2026-08-24 11:38:09 -07:00
datapath.h openvswitch: Fix CT limit teardown use-after-free 2026-08-24 11:38:09 -07:00
dp_notify.c net: replace use of system_wq with system_percpu_wq 2025-09-22 17:40:30 -07:00
drop.h net: openvswitch: add misc error drop reasons 2023-08-14 08:01:06 +01:00
flow_netlink.c net: openvswitch: reject oversized nested action attrs 2026-07-11 13:09:11 +02:00
flow_netlink.h net: openvswitch: remove never-working support for setting nsh fields 2025-11-14 18:13:24 -08:00
flow_table.c net: use get_random_u{16,32,64}() where appropriate 2026-04-09 19:27:43 -07:00
flow_table.h net: openvswitch: Annotate struct mask_array with __counted_by 2023-10-17 13:56:03 +02:00
flow.c net/openvswitch: check Ethernet header length in key_extract() 2026-08-04 13:02:17 +02:00
flow.h net: openvswitch: reduce cpu_used_mask memory 2023-02-06 22:36:29 -08:00
Kconfig openvswitch: remove support for legacy tunnel types 2026-08-06 15:09:23 +02:00
Makefile openvswitch: remove support for legacy tunnel types 2026-08-06 15:09:23 +02:00
meter.c net: openvswitch: fix potential UAF on meter attach failure 2026-07-30 13:20:03 +02:00
meter.h net: openvswitch: remove unnecessary linux/genetlink.h include 2024-04-01 21:44:34 -07:00
openvswitch_trace.c
openvswitch_trace.h tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
vport-internal_dev.c net: rename netns_local to netns_immutable 2025-03-04 12:44:48 +01:00
vport-internal_dev.h
vport-netdev.c openvswitch: remove support for legacy tunnel types 2026-08-06 15:09:23 +02:00
vport-netdev.h openvswitch: remove support for legacy tunnel types 2026-08-06 15:09:23 +02:00
vport.c net: openvswitch: unexport ovs_vport_alloc/free 2026-08-13 18:33:35 -07:00
vport.h openvswitch: vport: remove infrastructure for separate modules 2026-08-06 15:09:23 +02:00