]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: ctnetlink: make event listener tracking global
authorFlorian Westphal <fw@strlen.de>
Mon, 20 Feb 2023 16:24:00 +0000 (17:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:55:24 +0000 (13:55 +0100)
commitbbf605134a8ba5a04502642f7df8eb8ef6dff254
tree08998d332737cc7cbd9cf7821ca8d9dc2c0944f0
parentd2ad2c7affa5df202cb379139349e952f43c37a8
netfilter: ctnetlink: make event listener tracking global

[ Upstream commit be769c376daee8464a7557f587981345e1ec7a0a ]

pernet tracking doesn't work correctly because other netns might have
set NETLINK_LISTEN_ALL_NSID on its event socket.

In this case its expected that events originating in other net
namespaces are also received.

Making pernet-tracking work while also honoring NETLINK_LISTEN_ALL_NSID
requires much more intrusive changes both in netlink and nfnetlink,
f.e. adding a 'setsockopt' callback that lets nfnetlink know that the
event socket entered (or left) ALL_NSID mode.

Move to global tracking instead: if there is an event socket anywhere
on the system, all net namespaces which have conntrack enabled and
use autobind mode will allocate the ecache extension.

netlink_has_listeners() returns false only if the given group has no
subscribers in any net namespace, the 'net' argument passed to
nfnetlink_has_listeners is only used to derive the protocol (nfnetlink),
it has no other effect.

For proper NETLINK_LISTEN_ALL_NSID-aware pernet tracking of event
listeners a new netlink_has_net_listeners() is also needed.

Fixes: 70bc2a1ffe92 ("netfilter: conntrack: add nf_conntrack_events autodetect mode")
Reported-by: Bryce Kahle <bryce.kahle@datadoghq.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/netfilter.h
include/net/netns/conntrack.h
net/netfilter/core.c
net/netfilter/nf_conntrack_ecache.c
net/netfilter/nfnetlink.c