From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Liping Zhang <zlpnobody@163.com>
Cc: netfilter-devel@vger.kernel.org, Liping Zhang <zlpnobody@gmail.com>
Subject: Re: [PATCH nf 2/2] netfilter: nfnl_cthelper: reject del request if helper obj is in use
Date: Fri, 14 Apr 2017 01:16:42 +0200 [thread overview]
Message-ID: <20170413231642.GA7338@salvia> (raw)
In-Reply-To: <1491726134-23686-3-git-send-email-zlpnobody@163.com>
On Sun, Apr 09, 2017 at 04:22:14PM +0800, Liping Zhang wrote:
> From: Liping Zhang <zlpnobody@gmail.com>
>
> We can still delete the ct helper even if it is in use, this will cause
> a use-after-free error. In more detail, I mean:
> # nfct helper add ssdp inet udp
> # iptables -t raw -A OUTPUT -p udp -j CT --helper ssdp
> # nfct helper delete ssdp //--> succeed!
>
> So add reference count to fix this issue, if ct helper is used by
> others, reject the delete request.
>
> Apply this patch:
> # nfct helper delete ssdp
> nfct v1.4.3: netlink error: Device or resource busy
>
> Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
> ---
> Also note, nft ct helper obj only exists in nf-next tree, so after this
> patch appeared in nf-next, I will send another patch to fix it.
>
> include/net/netfilter/nf_conntrack_helper.h | 2 ++
> net/netfilter/nf_conntrack_helper.c | 6 ++++++
> net/netfilter/nfnetlink_cthelper.c | 17 +++++++++++------
> 3 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
> index 65e1dcf..c7a9ad7 100644
> --- a/include/net/netfilter/nf_conntrack_helper.h
> +++ b/include/net/netfilter/nf_conntrack_helper.h
> @@ -9,6 +9,7 @@
>
> #ifndef _NF_CONNTRACK_HELPER_H
> #define _NF_CONNTRACK_HELPER_H
> +#include <linux/refcount.h>
> #include <net/netfilter/nf_conntrack.h>
> #include <net/netfilter/nf_conntrack_extend.h>
> #include <net/netfilter/nf_conntrack_expect.h>
> @@ -26,6 +27,7 @@ struct nf_conntrack_helper {
> struct hlist_node hnode; /* Internal use. */
>
> char name[NF_CT_HELPER_NAME_LEN]; /* name of the module */
> + refcount_t refcnt;
Should this new refcnt; thing be in the new struct nfnl_cthelper?
I think this refcount is only required by the userspace helper
infrastructure, not existing in-kernel helpers.
I think like that we can skip patch 1/2 in this series.
next prev parent reply other threads:[~2017-04-13 23:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-09 8:22 [PATCH nf 0/2] netfilter: reject cthelper del request if it is in use Liping Zhang
2017-04-09 8:22 ` [PATCH nf 1/2] netfilter: introduce nf_conntrack_helper_put helper function Liping Zhang
2017-04-09 8:22 ` [PATCH nf 2/2] netfilter: nfnl_cthelper: reject del request if helper obj is in use Liping Zhang
2017-04-13 23:16 ` Pablo Neira Ayuso [this message]
2017-04-13 23:37 ` Liping Zhang
2017-04-13 23:42 ` Pablo Neira Ayuso
2017-04-13 23:42 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170413231642.GA7338@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=zlpnobody@163.com \
--cc=zlpnobody@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).