From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 10/14] netfilter: ipset: Introduce RCU locking in the list type
Date: Wed, 3 Dec 2014 12:36:42 +0100 [thread overview]
Message-ID: <20141203113642.GA4122@salvia> (raw)
In-Reply-To: <alpine.DEB.2.10.1412031206530.21739@blackhole.kfki.hu>
On Wed, Dec 03, 2014 at 12:17:36PM +0100, Jozsef Kadlecsik wrote:
> On Tue, 2 Dec 2014, Pablo Neira Ayuso wrote:
>
> > On Sun, Nov 30, 2014 at 07:57:01PM +0100, Jozsef Kadlecsik wrote:
> > > Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> > > ---
> > > net/netfilter/ipset/ip_set_list_set.c | 386 ++++++++++++++++------------------
> > > 1 file changed, 182 insertions(+), 204 deletions(-)
> > >
> > > diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
> > > index f8f6828..323115a 100644
> > > --- a/net/netfilter/ipset/ip_set_list_set.c
> > > +++ b/net/netfilter/ipset/ip_set_list_set.c
> > > @@ -9,6 +9,7 @@
> > >
> > > #include <linux/module.h>
> > > #include <linux/ip.h>
> > > +#include <linux/rculist.h>
> > > #include <linux/skbuff.h>
> > > #include <linux/errno.h>
> > >
> > > @@ -27,6 +28,8 @@ MODULE_ALIAS("ip_set_list:set");
> > >
> > > /* Member elements */
> > > struct set_elem {
> > > + struct rcu_head rcu;
> > > + struct list_head list;
> >
> > I think rcu_barrier() in the module removal path is missing to make
> > sure call_rcu() is called before the module is gone.
>
> The module can be removed only when there isn't a single set of the given
> type. That means there are no elements to be removed by kfree_rcu().
> Therefore I think rcu_barrier() is not required in the module removal
> path.
I think this can race with the rcu callback execution. See this:
https://www.kernel.org/doc/Documentation/RCU/rcubarrier.txt
specifically: Unloading Modules That Use call_rcu()
[...]
> > > + /* Can we replace a timed out entry? */
> > > + if (n != NULL &&
> > > + !(SET_WITH_TIMEOUT(set) &&
> > > + ip_set_timeout_expired(ext_timeout(n, set))))
> > > + n = NULL;
> > > +
> > > + e = kzalloc(set->dsize, GFP_KERNEL);
> > > + if (!e)
> > > + return -ENOMEM;
> > > + e->id = d->id;
> > > + INIT_LIST_HEAD(&e->list);
> > > + list_set_init_extensions(set, ext, e);
> > > + if (n)
> > > + list_set_replace(set, e, n);
> > > + else if (next)
> > > + list_add_tail_rcu(&e->list, &next->list);
> > > + else if (prev)
> > > + list_add_rcu(&e->list, &prev->list);
> > > + else
> > > + list_add_tail_rcu(&e->list, &map->members);
> > > + spin_unlock_bh(&set->lock);
> > > +
> > > + synchronize_rcu_bh();
> >
> > I suspect you don't need this. What is your intention here?
>
> Here the userspace adds/deletes/replaces an element in the list type of
> set and in the meantime the kernel module can traverse the same linked
> list. In the replace case we remove and delete the old entry, therefore
> the call to synchronize_rcu_bh(). That could be called from a condition
> then, to express the case.
But you're releasing objects via kfree_rcu(), right? Then you don't
need to wait for the rcu grace state.
next prev parent reply other threads:[~2014-12-03 11:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-30 18:56 [PATCH 00/10] ipset patches for nf-next, v2 Jozsef Kadlecsik
2014-11-30 18:56 ` [PATCH 01/14] netfilter: ipset: Support updating extensions when the set is full Jozsef Kadlecsik
2014-12-02 18:46 ` Pablo Neira Ayuso
2014-12-02 18:50 ` Pablo Neira Ayuso
2014-12-03 11:26 ` Jozsef Kadlecsik
2014-12-03 11:56 ` Pablo Neira Ayuso
2014-11-30 18:56 ` [PATCH 02/14] netfilter: ipset: Alignment problem between 64bit kernel 32bit userspace Jozsef Kadlecsik
2014-11-30 18:56 ` [PATCH 03/14] netfilter: ipset: Indicate when /0 networks are supported Jozsef Kadlecsik
2014-11-30 18:56 ` [PATCH 04/14] netfilter: ipset: Simplify cidr handling for hash:*net* types Jozsef Kadlecsik
2014-11-30 18:56 ` [PATCH 05/14] netfilter: ipset: Allocate the proper size of memory when /0 networks are supported Jozsef Kadlecsik
2014-11-30 18:56 ` [PATCH 06/14] netfilter: ipset: Explicitly add padding elements to hash:net,net and hash:net,port,net Jozsef Kadlecsik
2014-11-30 18:56 ` [PATCH 07/14] netfilter: ipset: Remove rbtree from hash:net,iface in order to run under RCU Jozsef Kadlecsik
2014-12-02 18:23 ` Pablo Neira Ayuso
2014-12-03 10:54 ` Jozsef Kadlecsik
2014-11-30 18:56 ` [PATCH 08/14] netfilter: ipset: Introduce RCU locking instead of rwlock per set in the core Jozsef Kadlecsik
2014-12-02 18:25 ` Pablo Neira Ayuso
2014-12-03 11:01 ` Jozsef Kadlecsik
2014-11-30 18:57 ` [PATCH 09/14] netfilter: ipset: Introduce RCU locking in the bitmap types Jozsef Kadlecsik
2014-11-30 18:57 ` [PATCH 10/14] netfilter: ipset: Introduce RCU locking in the list type Jozsef Kadlecsik
2014-12-02 18:35 ` Pablo Neira Ayuso
2014-12-02 18:52 ` Pablo Neira Ayuso
2014-12-03 11:17 ` Jozsef Kadlecsik
2014-12-03 11:36 ` Pablo Neira Ayuso [this message]
2014-11-30 18:57 ` [PATCH 11/14] netfilter: ipset: Introduce RCU locking in the hash types Jozsef Kadlecsik
2014-12-01 7:59 ` Jesper Dangaard Brouer
2014-12-02 18:40 ` Pablo Neira Ayuso
2014-12-03 11:23 ` Jozsef Kadlecsik
2014-11-30 18:57 ` [PATCH 12/14] netfilter: ipset: styles warned by checkpatch.pl fixed Jozsef Kadlecsik
2014-12-02 18:43 ` Pablo Neira Ayuso
2014-12-03 11:25 ` Jozsef Kadlecsik
2014-11-30 18:57 ` [PATCH 13/14] netfilter: ipset: Fix parallel resizing and listing of the same set Jozsef Kadlecsik
2014-11-30 18:57 ` [PATCH 14/14] netfilter: ipset: Fix sparse warning Jozsef Kadlecsik
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=20141203113642.GA4122@salvia \
--to=pablo@netfilter.org \
--cc=kadlec@blackhole.kfki.hu \
--cc=netfilter-devel@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).