Skip to contentSkip to conversation

netfilter: remove nf_conntrack_helper sysctl toggle

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Aug 26, 2022 – Aug 29, 2022

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: remove nf_conntrack_helper sysctl toggle

__nf_ct_try_assign_helper() remains in place but it now requires a template to configure the helper.

A toggle to disable automatic helper assignment was added by:

a9006892643a ("netfilter: nf_ct_helper: allow to disable automatic helper assignment")

in 2012 to address the issues described in "Secure use of iptables and connection tracking helpers". Automatic conntrack helper assignment was disabled by:

3bb398d925ec ("netfilter: nf_ct_helper: disable automatic helper assignment")

back in 2016.

This patch removes the sysctl toggle, users now have to rely on explicit conntrack helper configuration via ruleset.

---
 include/net/netfilter/nf_conntrack.h    |  2 -
 include/net/netns/conntrack.h           |  1 -
 net/netfilter/nf_conntrack_core.c       |  5 --
 net/netfilter/nf_conntrack_helper.c     | 80 ++++---------------------
 net/netfilter/nf_conntrack_netlink.c    |  5 --
 net/netfilter/nf_conntrack_standalone.c | 10 ----
 net/netfilter/nft_ct.c                  |  3 -
 7 files changed, 10 insertions(+), 96 deletions(-)
include/net/netfilter/nf_conntrack.h +0 -2
index a32be8aa7ed2..6a2019aaa464 100644
@@ -53,8 +53,6 @@ struct nf_conntrack_net {
 	/* only used when new connection is allocated: */
 	atomic_t count;
 	unsigned int expect_count;
-	u8 sysctl_auto_assign_helper;
-	bool auto_assign_helper_warned;
 
 	/* only used from work queues, configuration plane, and so on: */
 	unsigned int users4;
include/net/netns/conntrack.h +0 -1
index c396a3862e80..e1290c159184 100644
@@ -101,7 +101,6 @@ struct netns_ct {
 	u8			sysctl_log_invalid; /* Log invalid packets */
 	u8			sysctl_events;
 	u8			sysctl_acct;
-	u8			sysctl_auto_assign_helper;
 	u8			sysctl_tstamp;
 	u8			sysctl_checksum;
 
net/netfilter/nf_conntrack_core.c +0 -5
index 71c2f4f95d36..c07bb87ff1be 100644
@@ -2068,10 +2068,6 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
 	ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
 	if (ct->master || (help && !hlist_empty(&help->expectations)))
 		return;
-
-	rcu_read_lock();
-	__nf_ct_try_assign_helper(ct, NULL, GFP_ATOMIC);
-	rcu_read_unlock();
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
 
@@ -2797,7 +2793,6 @@ int nf_conntrack_init_net(struct net *net)
 	nf_conntrack_acct_pernet_init(net);
 	nf_conntrack_tstamp_pernet_init(net);
 	nf_conntrack_ecache_pernet_init(net);
-	nf_conntrack_helper_pernet_init(net);
 	nf_conntrack_proto_pernet_init(net);
 
 	return 0;
net/netfilter/nf_conntrack_helper.c +10 -70

120 lines not on this page · raw message

net/netfilter/nf_conntrack_netlink.c +0 -5
index 04169b54f2a2..7562b215b932 100644
@@ -2298,11 +2298,6 @@ ctnetlink_create_conntrack(struct net *net,
 			ct->status |= IPS_HELPER;
 			RCU_INIT_POINTER(help->helper, helper);
 		}
-	} else {
-		/* try an implicit helper assignation */
-		err = __nf_ct_try_assign_helper(ct, NULL, GFP_ATOMIC);
-		if (err < 0)
-			goto err2;
 	}
 
 	err = ctnetlink_setup_nat(ct, cda);
net/netfilter/nf_conntrack_standalone.c +0 -10
index 05895878610c..4ffe84c5a82c 100644
@@ -561,7 +561,6 @@ enum nf_ct_sysctl_index {
 	NF_SYSCTL_CT_LOG_INVALID,
 	NF_SYSCTL_CT_EXPECT_MAX,
 	NF_SYSCTL_CT_ACCT,
-	NF_SYSCTL_CT_HELPER,
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
 	NF_SYSCTL_CT_EVENTS,
 #endif
@@ -680,14 +679,6 @@ static struct ctl_table nf_ct_sysctl_table[] = {
 		.extra1 	= SYSCTL_ZERO,
 		.extra2 	= SYSCTL_ONE,
 	},
-	[NF_SYSCTL_CT_HELPER] = {
-		.procname	= "nf_conntrack_helper",
-		.maxlen		= sizeof(u8),
-		.mode		= 0644,
-		.proc_handler	= proc_dou8vec_minmax,
-		.extra1 	= SYSCTL_ZERO,
-		.extra2 	= SYSCTL_ONE,
-	},
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
 	[NF_SYSCTL_CT_EVENTS] = {
 		.procname	= "nf_conntrack_events",
@@ -1100,7 +1091,6 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
 	table[NF_SYSCTL_CT_CHECKSUM].data = &net->ct.sysctl_checksum;
 	table[NF_SYSCTL_CT_LOG_INVALID].data = &net->ct.sysctl_log_invalid;
 	table[NF_SYSCTL_CT_ACCT].data = &net->ct.sysctl_acct;
-	table[NF_SYSCTL_CT_HELPER].data = &cnet->sysctl_auto_assign_helper;
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
 	table[NF_SYSCTL_CT_EVENTS].data = &net->ct.sysctl_events;
 #endif
net/netfilter/nft_ct.c +0 -3
index b04995c3e17f..a3f01f209a53 100644
@@ -1089,9 +1089,6 @@ static int nft_ct_helper_obj_init(const struct nft_ctx *ctx,
 	if (err < 0)
 		goto err_put_helper;
 
-	/* Avoid the bogus warning, helper will be assigned after CT init */
-	nf_ct_set_auto_assign_helper_warned(ctx->net);
-
 	return 0;
 
 err_put_helper:
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Pablo Neira Ayuso

__nf_ct_try_assign_helper() remains in place but it now requires a template to configure the helper.

A toggle to disable automatic helper assignment was added by:

a9006892643a ("netfilter: nf_ct_helper: allow to disable automatic helper assignment")

in 2012 to address the issues described in "Secure use of iptables and connection tracking helpers". Automatic conntrack helper assignment was disabled by:

3bb398d925ec ("netfilter: nf_ct_helper: disable automatic helper assignment")

Quoted 7 lines

back in 2016.

This patch removes the sysctl toggle, users now have to rely on explicit conntrack helper configuration via ruleset.

---

Ilya / Pravin,

We will likely need to make a change in the ovs test-suite from:

sysctl -w net.netfilter.nf_conntrack_helper=0

to:

sysctl -ew net.netfilter.nf_conntrack_helper=0

I will cook up a quick patch

-Aaron