Skip to content

Commit 6812247

Browse files
JonathonReinhartgregkh
authored andcommitted
netfilter: conntrack: Make global sysctls readonly in non-init netns
commit 2671fa4 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 d0febd8 ("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: d0febd8 ("netfilter: conntrack: re-visit sysctls in unprivileged namespaces") Signed-off-by: Jonathon Reinhart <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c386907 commit 6812247

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/netfilter/nf_conntrack_standalone.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,11 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
631631
if (net->user_ns != &init_user_ns)
632632
table[0].procname = NULL;
633633

634-
if (!net_eq(&init_net, net))
634+
if (!net_eq(&init_net, net)) {
635+
table[0].mode = 0444;
635636
table[2].mode = 0444;
637+
table[5].mode = 0444;
638+
}
636639

637640
net->ct.sysctl_header = register_net_sysctl(net, "net/netfilter", table);
638641
if (!net->ct.sysctl_header)

0 commit comments

Comments
 (0)