Skip to content

Commit da50f56

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 a36d9ba commit da50f56

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

554-
if (!net_eq(&init_net, net))
554+
if (!net_eq(&init_net, net)) {
555+
table[0].mode = 0444;
555556
table[2].mode = 0444;
557+
table[5].mode = 0444;
558+
}
556559

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

0 commit comments

Comments
 (0)