From: Daniel Borkmann <daniel@iogearbox.net>
To: Cong Wang <cwang@twopensource.com>
Cc: David Miller <davem@davemloft.net>,
Alexei Starovoitov <ast@plumgrid.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net] net: sched: fix refcount imbalance in actions
Date: Thu, 30 Jul 2015 02:55:39 +0200 [thread overview]
Message-ID: <55B9760B.10004@iogearbox.net> (raw)
In-Reply-To: <CAHA+R7MVFhv1_J=0QE6zjCiVtCCKsaU=WgX6eH-u3op7GLZW5w@mail.gmail.com>
On 07/30/2015 02:33 AM, Cong Wang wrote:
...
> diff --git a/net/sched/act_api.c b/net/sched/act_api.c
> index af427a3..bd63a39 100644
> --- a/net/sched/act_api.c
> +++ b/net/sched/act_api.c
> @@ -53,8 +53,11 @@ int tcf_hash_release(struct tc_action *a, int bind)
> if (p) {
> if (bind)
> p->tcfc_bindcnt--;
> - else if (p->tcfc_bindcnt > 0)
> - return -EPERM;
> + else {
> + if (p->tcfc_bindcnt > 0)
> + return -EPERM;
> + return ret;
> + }
Hm, so this seems not correct: if we only ever increase tcfc_refcnt
when there's bind=1, and only ever decrease when bind=1, then we
will never free the action as we do start out from ref=1 in case
it has been added without initial binding, if I see this correctly.
> p->tcfc_refcnt--;
> if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) {
> @@ -214,9 +217,10 @@ int tcf_hash_check(u32 index, struct tc_action
> *a, int bind)
> struct tcf_hashinfo *hinfo = a->ops->hinfo;
> struct tcf_common *p = NULL;
> if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) {
> - if (bind)
> + if (bind) {
> p->tcfc_bindcnt++;
> - p->tcfc_refcnt++;
> + p->tcfc_refcnt++;
> + }
> a->priv = p;
> return 1;
> }
> diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
> index a42a3b2..2685450 100644
> --- a/net/sched/act_mirred.c
> +++ b/net/sched/act_mirred.c
> @@ -98,6 +98,8 @@ static int tcf_mirred_init(struct net *net, struct
> nlattr *nla,
> return ret;
> ret = ACT_P_CREATED;
> } else {
> + if (bind)
> + return 0;
> if (!ovr) {
> tcf_hash_release(a, bind);
> return -EEXIST;
>
next prev parent reply other threads:[~2015-07-30 0:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-29 21:35 [PATCH net] net: sched: fix refcount imbalance in actions Daniel Borkmann
2015-07-30 0:33 ` Cong Wang
2015-07-30 0:55 ` Daniel Borkmann [this message]
2015-07-30 18:48 ` Cong Wang
2015-07-30 20:01 ` Daniel Borkmann
2015-07-30 21:21 ` David Miller
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=55B9760B.10004@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ast@plumgrid.com \
--cc=cwang@twopensource.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=netdev@vger.kernel.org \
/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).