summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathon Reinhart <jonathon.reinhart@gmail.com>2021-04-12 00:24:53 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-22 10:40:33 +0200
commitda50f56e826e1db141693297afb99370ebc160dd (patch)
tree9b7eef18e2fba0241bdc88c055530aee7f31857c
parenta36d9baf46fdc29ce7febc5b3dbf95fa7bfc032b (diff)
downloadlinux-stable-da50f56e826e1db141693297afb99370ebc160dd.tar.gz
linux-stable-da50f56e826e1db141693297afb99370ebc160dd.tar.bz2
linux-stable-da50f56e826e1db141693297afb99370ebc160dd.zip
netfilter: conntrack: Make global sysctls readonly in non-init netns
commit 2671fa4dc0109d3fb581bc3078fdf17b5d9080f6 upstream. 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 d0febd81ae77 ("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: d0febd81ae77 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/netfilter/nf_conntrack_standalone.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 0dbd17137dee..039fc7c539e2 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -551,8 +551,11 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
if (net->user_ns != &init_user_ns)
table[0].procname = NULL;
- if (!net_eq(&init_net, net))
+ if (!net_eq(&init_net, net)) {
+ table[0].mode = 0444;
table[2].mode = 0444;
+ table[5].mode = 0444;
+ }
net->ct.sysctl_header = register_net_sysctl(net, "net/netfilter", table);
if (!net->ct.sysctl_header)