Skip to content

Commit baea536

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 fb80624 commit baea536

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
@@ -1071,8 +1071,11 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
10711071
#endif
10721072
}
10731073

1074-
if (!net_eq(&init_net, net))
1074+
if (!net_eq(&init_net, net)) {
1075+
table[NF_SYSCTL_CT_MAX].mode = 0444;
1076+
table[NF_SYSCTL_CT_EXPECT_MAX].mode = 0444;
10751077
table[NF_SYSCTL_CT_BUCKETS].mode = 0444;
1078+
}
10761079

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

0 commit comments

Comments
 (0)