netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Liping Zhang <zlpnobody@163.com>
Cc: netfilter-devel@vger.kernel.org,
	Liping Zhang <liping.zhang@spreadtrum.com>
Subject: Re: [PATCH nf 1/2] netfilter: nfnetlink_acct: fix race between nfacct del and xt_nfacct destroy
Date: Thu, 18 Aug 2016 00:26:34 +0200	[thread overview]
Message-ID: <20160817222634.GA2798@salvia> (raw)
In-Reply-To: <1471101182-15294-1-git-send-email-zlpnobody@163.com>

On Sat, Aug 13, 2016 at 11:13:01PM +0800, Liping Zhang wrote:
> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> Suppose that we input the following commands at first:
>   # nfacct add test
>   # iptables -A INPUT -m nfacct --nfacct-name test
> 
> And now "test" acct's refcnt is 2, but later when we try to delete the
> "test" nfacct and the related iptables rule at the same time, race maybe
> happen:
>       CPU0                                    CPU1
>   nfnl_acct_try_del                      nfnl_acct_put
>   atomic_dec_and_test //ref=1,testfail          -
>        -                                 atomic_dec_and_test //ref=0,testok
>        -                                 kfree_rcu
>   atomic_inc //ref=1                            -
> 
> So after the rcu grace period, nf_acct will be freed but it is still linked
> in the nfnl_acct_list, and we can access it later, then oops will happen.
> 
> Convert atomic_dec_and_test and atomic_inc combinaiton to one atomic
> operation atomic_cmpxchg here to fix this problem.

Applied, thanks.

  parent reply	other threads:[~2016-08-17 22:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-13 15:13 [PATCH nf 1/2] netfilter: nfnetlink_acct: fix race between nfacct del and xt_nfacct destroy Liping Zhang
2016-08-13 15:13 ` [PATCH nf 2/2] netfilter: nfnetlink_acct: report overquota to the right netns Liping Zhang
2016-08-17 22:26   ` Pablo Neira Ayuso
2016-08-17 22:26 ` Pablo Neira Ayuso [this message]
2016-08-17 22:37   ` [PATCH nf 1/2] netfilter: nfnetlink_acct: fix race between nfacct del and xt_nfacct destroy Pablo Neira Ayuso
2016-08-18 10:41     ` Liping Zhang
2016-08-18 14:55       ` 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=20160817222634.GA2798@salvia \
    --to=pablo@netfilter.org \
    --cc=liping.zhang@spreadtrum.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=zlpnobody@163.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).