Patch "netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
netfilter-nf_ct_helper-permit-cthelpers-with-different-names-via-nfnetlink.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Thu Mar 22 14:40:23 CET 2018
From: Liping Zhang <[email protected]>
Date: Sat, 15 Apr 2017 19:27:42 +0800
Subject: netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink
From: Liping Zhang <[email protected]>
[ Upstream commit 66e5a6b18bd09d0431e97cd3c162e76c5c2aebba ]
cthelpers added via nfnetlink may have the same tuple, i.e. except for the l3proto and l4proto, other fields are all zero. So even with the different names, we will also fail to add them:
# nfct helper add ssdp inet udp # nfct helper add tftp inet udp nfct v1.4.3: netlink error: File exists
So in order to avoid unpredictable behaviour, we should:
1. cthelpers can be selected by nft ct helper obj or xt_CT target, so report error if duplicated { name, l3proto, l4proto } tuple exist.
2. cthelpers can be selected by nf_ct_tuple_src_mask_cmp when nf_ct_auto_assign_helper is enabled, so also report error if duplicated { l3proto, l4proto, src-port } tuple exist.
Also note, if the cthelper is added from userspace, then the src-port will always be zero, it's invalid for nf_ct_auto_assign_helper, so there's no need to check the second point listed above.
--- net/netfilter/nf_conntrack_helper.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
net/netfilter/nf_conntrack_helper.c +21 -5
@@ -379,17 +379,33 @@ int nf_conntrack_helper_register(structstruct nf_conntrack_tuple_mask mask = { .src.u.all =htons (0xFFFF ) };unsigned int h =helper_hash (&me->tuple);struct nf_conntrack_helper *cur; -int ret =0 ; +int ret =0 , i;BUG_ON (me->expect_policy ==NULL );BUG_ON (me->expect_class_max >=NF_CT_MAX_EXPECT_CLASSES );BUG_ON (strlen (me->name) >NF_CT_HELPER_NAME_LEN -1 );mutex_lock (&nf_ct_helper_mutex); -hlist_for_each_entry (cur, &nf_ct_helper_hash[h], hnode) { -if (nf_ct_tuple_src_mask_cmp (&cur->tuple, &me->tuple, &mask)) { - ret = -EEXIST ; - goto out; +for (i =0 ; i < nf_ct_helper_hsize; i++) { +hlist_for_each_entry (cur, &nf_ct_helper_hash[i], hnode) { +if (!strcmp (cur->name, me->name) && + (cur->tuple.src.l3num ==NFPROTO_UNSPEC || + cur->tuple.src.l3num == me->tuple.src.l3num) && + cur->tuple.dst.protonum == me->tuple.dst.protonum) { + ret = -EEXIST ; + goto out; + } + } + } + +/* avoid unpredictable behaviour for auto_assign_helper */ +if (!(me->flags &NF_CT_HELPER_F_USERSPACE )) { +hlist_for_each_entry (cur, &nf_ct_helper_hash[h], hnode) { +if (nf_ct_tuple_src_mask_cmp (&cur->tuple, &me->tuple, + &mask)) { + ret = -EEXIST ; + goto out; + } } }hlist_add_head_rcu (&me->hnode, &nf_ct_helper_hash[h]);
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/netfilter-nf_ct_helper-permit-cthelpers-with-different-names-via-nfnetlink.patch queue-4.9/netfilter-xt_ct-fix-refcnt-leak-on-error-path.patch queue-4.9/netfilter-nft_dynset-continue-to-next-expr-if-_op_add-succeeded.patch