Skip to content

Commit 9b28847

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 1ea5cdd commit 9b28847

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
@@ -594,8 +594,11 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
594594
if (net->user_ns != &init_user_ns)
595595
table[0].procname = NULL;
596596

597-
if (!net_eq(&init_net, net))
597+
if (!net_eq(&init_net, net)) {
598+
table[0].mode = 0444;
598599
table[2].mode = 0444;
600+
table[5].mode = 0444;
601+
}
599602

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

0 commit comments

Comments
 (0)