From: Eric Dumazet <eric.dumazet@gmail.com>
To: Yanmin Zhang <yanmin_zhang@linux.intel.com>
Cc: David Miller <davem@davemloft.net>,
kunx.jiang@intel.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipv4: fix the rcu race between free_fib_info and ip_route_output_slow
Date: Wed, 23 May 2012 09:39:34 +0200 [thread overview]
Message-ID: <1337758775.3361.2056.camel@edumazet-glaptop> (raw)
In-Reply-To: <1337757862.14538.199.camel@ymzhang.sh.intel.com>
On Wed, 2012-05-23 at 15:24 +0800, Yanmin Zhang wrote:
> On Wed, 2012-05-23 at 09:13 +0200, Eric Dumazet wrote:
> > On Wed, 2012-05-23 at 08:55 +0200, Eric Dumazet wrote:
> >
> > > Please hold on, I'll send a v2
> >
> > I believe your patch should be fine, if you move back the
> > fib_info_cnt--;
> >
> > So only do the dev_put() in free_fib_info_rcu().
> We would do so in a new patch.
>
> >
> > No need to clear nh_dev to NULL since we are freeing fi at the end of
> > function.
> David suggests to reset it to NULL to detect other potential
> race conditions.
>
Yes but no.
Users are in a RCU read lock and we should not change nh_dev to NULL
while they are running.
Thats what I tried to do (David message gave me this wrong hint) but it
came to a dead issue.
Only after a grace period we can :
dev_put() all involved net_devices
kfree(fi)
> Besides above suggestions, how do you think about:
>
> fib_create_info=>fib_find_info, but fib_find_info is not protected by
> fib_info_lock. See the codes:
>
> fib_create_info()
> {
> ...
> link_it:
> ofi = fib_find_info(fi);
> if (ofi) {
> fi->fib_dead = 1;
> free_fib_info(fi);
> ofi->fib_treeref++;
> return ofi;
> }
> fi->fib_treeref++;
> atomic_inc(&fi->fib_clntref);
> spin_lock_bh(&fib_info_lock);
>
> ...
> }
>
> I plan to change it to hold fib_info_lock before calling fib_find_info. Is
> it ok for you?
Its not needed we hold RTNL mutex.
spinlock is needed mainly because of ip_fib_check_default(), but this
could be changed to use RCU as well.
(readers use RCU, writers already hold RTNL -> no more fib_info_lock )
next prev parent reply other threads:[~2012-05-23 7:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-22 9:48 [PATCH] ipv4: fix the rcu race between free_fib_info and ip_route_output_slow kun.jiang
2012-05-22 19:15 ` David Miller
2012-05-23 3:02 ` Yanmin Zhang
2012-05-23 3:23 ` David Miller
2012-05-23 3:30 ` Yanmin Zhang
2012-05-23 3:49 ` David Miller
2012-05-23 4:41 ` Yanmin Zhang
2012-05-23 5:08 ` Eric Dumazet
2012-05-23 4:37 ` Eric Dumazet
2012-05-23 4:54 ` Yanmin Zhang
2012-05-23 5:02 ` Eric Dumazet
2012-05-23 6:15 ` Yanmin Zhang
2012-05-23 6:27 ` Eric Dumazet
2012-05-23 6:47 ` Yanmin Zhang
2012-05-23 6:55 ` Eric Dumazet
2012-05-23 7:13 ` Eric Dumazet
2012-05-23 7:24 ` Yanmin Zhang
2012-05-23 7:39 ` Eric Dumazet [this message]
2012-05-23 7:41 ` Eric Dumazet
2012-05-23 7:47 ` Yanmin Zhang
2012-05-23 6:37 ` Eric Dumazet
2012-05-23 6:43 ` Eric Dumazet
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=1337758775.3361.2056.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=kunx.jiang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yanmin_zhang@linux.intel.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