]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: conntrack: Make global sysctls readonly in non-init netns
authorJonathon Reinhart <jonathon.reinhart@gmail.com>
Mon, 12 Apr 2021 04:24:53 +0000 (00:24 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Apr 2021 20:27:11 +0000 (13:27 -0700)
commitfffe991b934932ed684c4a2c0e4e5f16ea29611f
tree4f871cebe602618f0bf13b51746d9499c9b7cca9
parent47990214dcd791ac953371b2f22fe253307cff76
netfilter: conntrack: Make global sysctls readonly in non-init netns

These sysctls point to global variables:
- NF_SYSCTL_CT_MAX (&nf_conntrack_max)
- NF_SYSCTL_CT_EXPECT_MAX (&nf_ct_expect_max)
- NF_SYSCTL_CT_BUCKETS (&nf_conntrack_htable_size_user)

Because their data pointers are not updated to point to per-netns
structures, they must be marked read-only in a non-init_net ns.
Otherwise, changes in any net namespace are reflected in (leaked into)
all other net namespaces. This problem has existed since the
introduction of net namespaces.

The current logic marks them read-only only if the net namespace is
owned by an unprivileged user (other than init_user_ns).

Commit 7ada75fbb28c ("netfilter: conntrack: re-visit sysctls in
unprivileged namespaces") "exposes all sysctls even if the namespace is
unpriviliged." Since we need to mark them readonly in any case, we can
forego the unprivileged user check altogether.

Fixes: 7ada75fbb28c ("netfilter: conntrack: re-visit sysctls in unprivileged namespaces")
Signed-off-by: Jonathon Reinhart <Jonathon.Reinhart@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netfilter/nf_conntrack_standalone.c