Skip to content

Commit d0febd8

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: conntrack: re-visit sysctls in unprivileged namespaces
since commit b884fa4 ("netfilter: conntrack: unify sysctl handling") conntrack no longer exposes most of its sysctls (e.g. tcp timeouts settings) to network namespaces that are not owned by the initial user namespace. This patch exposes all sysctls even if the namespace is unpriviliged. compared to a 4.19 kernel, the newly visible and writeable sysctls are: net.netfilter.nf_conntrack_acct net.netfilter.nf_conntrack_timestamp .. to allow to enable accouting and timestamp extensions. net.netfilter.nf_conntrack_events .. to turn off conntrack event notifications. net.netfilter.nf_conntrack_checksum .. to disable checksum validation. net.netfilter.nf_conntrack_log_invalid .. to enable logging of packets deemed invalid by conntrack. newly visible sysctls that are only exported as read-only: net.netfilter.nf_conntrack_count .. current number of conntrack entries living in this netns. net.netfilter.nf_conntrack_max .. global upperlimit (maximum size of the table). net.netfilter.nf_conntrack_buckets .. size of the conntrack table (hash buckets). net.netfilter.nf_conntrack_expect_max .. maximum number of permitted expectations in this netns. net.netfilter.nf_conntrack_helper .. conntrack helper auto assignment. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 339706b commit d0febd8

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

net/netfilter/nf_conntrack_standalone.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,21 +1054,18 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
10541054
nf_conntrack_standalone_init_dccp_sysctl(net, table);
10551055
nf_conntrack_standalone_init_gre_sysctl(net, table);
10561056

1057-
/* Don't export sysctls to unprivileged users */
1057+
/* Don't allow unprivileged users to alter certain sysctls */
10581058
if (net->user_ns != &init_user_ns) {
1059-
table[NF_SYSCTL_CT_MAX].procname = NULL;
1060-
table[NF_SYSCTL_CT_ACCT].procname = NULL;
1061-
table[NF_SYSCTL_CT_HELPER].procname = NULL;
1062-
#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
1063-
table[NF_SYSCTL_CT_TIMESTAMP].procname = NULL;
1064-
#endif
1059+
table[NF_SYSCTL_CT_MAX].mode = 0444;
1060+
table[NF_SYSCTL_CT_EXPECT_MAX].mode = 0444;
1061+
table[NF_SYSCTL_CT_HELPER].mode = 0444;
10651062
#ifdef CONFIG_NF_CONNTRACK_EVENTS
1066-
table[NF_SYSCTL_CT_EVENTS].procname = NULL;
1063+
table[NF_SYSCTL_CT_EVENTS].mode = 0444;
10671064
#endif
1068-
}
1069-
1070-
if (!net_eq(&init_net, net))
10711065
table[NF_SYSCTL_CT_BUCKETS].mode = 0444;
1066+
} else if (!net_eq(&init_net, net)) {
1067+
table[NF_SYSCTL_CT_BUCKETS].mode = 0444;
1068+
}
10721069

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

0 commit comments

Comments
 (0)