Skip to content

Commit d1ca60e

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ctnetlink: disable helper autoassign
When userspace, e.g. conntrackd, inserts an entry with a specified helper, its possible that the helper is lost immediately after its added: ctnetlink_create_conntrack -> nf_ct_helper_ext_add + assign helper -> ctnetlink_setup_nat -> ctnetlink_parse_nat_setup -> parse_nat_setup -> nfnetlink_parse_nat_setup -> nf_nat_setup_info -> nf_conntrack_alter_reply -> __nf_ct_try_assign_helper ... and __nf_ct_try_assign_helper will zero the helper again. Set IPS_HELPER bit to bypass auto-assign logic, its unwanted, just like when helper is assigned via ruleset. Dropped old 'not strictly necessary' comment, it referred to use of rcu_assign_pointer() before it got replaced by RCU_INIT_POINTER(). NB: Fixes tag intentionally incorrect, this extends the referenced commit, but this change won't build without IPS_HELPER introduced there. Fixes: 6714cf5 ("netfilter: nf_conntrack: fix explicit helper attachment and NAT") Reported-by: Pham Thanh Tuyen <phamtyn@gmail.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 1f6339e commit d1ca60e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

include/uapi/linux/netfilter/nf_conntrack_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ enum ip_conntrack_status {
106106
IPS_NAT_CLASH = IPS_UNTRACKED,
107107
#endif
108108

109-
/* Conntrack got a helper explicitly attached via CT target. */
109+
/* Conntrack got a helper explicitly attached (ruleset, ctnetlink). */
110110
IPS_HELPER_BIT = 13,
111111
IPS_HELPER = (1 << IPS_HELPER_BIT),
112112

net/netfilter/nf_conntrack_netlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,8 @@ ctnetlink_create_conntrack(struct net *net,
23112311
if (helper->from_nlattr)
23122312
helper->from_nlattr(helpinfo, ct);
23132313

2314-
/* not in hash table yet so not strictly necessary */
2314+
/* disable helper auto-assignment for this entry */
2315+
ct->status |= IPS_HELPER;
23152316
RCU_INIT_POINTER(help->helper, helper);
23162317
}
23172318
} else {

0 commit comments

Comments
 (0)