From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Eric Paris <eparis@parisplace.org>
Cc: Dave Jones <davej@redhat.com>,
sds@tycho.nsa.gov, Linux Kernel <linux-kernel@vger.kernel.org>,
paul@paul-moore.com
Subject: Re: suspicious RCU usage in security/selinux/netnode.c
Date: Tue, 15 May 2012 07:46:58 -0700 [thread overview]
Message-ID: <20120515144658.GC2461@linux.vnet.ibm.com> (raw)
In-Reply-To: <CACLa4psGwEC96GfonAJ+-v0ocdvb_ZBxB6v=zAXbnbqFmuCNuA@mail.gmail.com>
On Tue, May 15, 2012 at 10:24:23AM -0400, Eric Paris wrote:
> On Tue, May 15, 2012 at 1:16 AM, Paul E. McKenney
> <paulmck@linux.vnet.ibm.com> wrote:
> > On Tue, May 15, 2012 at 12:41:45AM -0400, Dave Jones wrote:
> >> I just triggered this on Linus' current tree.
> >
> > This is a bare:
> >
> > rcu_dereference(sel_netnode_hash[idx].list.prev)
> >
> > which needs to be in an RCU read-side critical section. Alternatively,
> > the above should instead be something like:
> >
> > rcu_dereference_check(sel_netnode_hash[idx].list.prev,
> > lockdep_is_held(&sel_netnode_lock));
>
> Right, but that 'bare' dereference comes from
> list_for_each_entry_rcu(), [from sel_netnode_sid_slow()] which I don't
> see how to easily annotate with the lock. Nor do I think it's within
> my brain power (or my willingness to maintain such in the future) to
> want to open code that logic.
You lost me on this one. The lockdep splat called out the
rcu_dereference() above, not a list_for_each_entry_rcu(). Besides which,
the list_for_each_entry_rcu() does not do the checking -- at the time,
I was not willing to explode the API that much.
> Should we just take the rcu_read_lock() where we take the spinlock?
> Is that a perf hit and figuring out how to do the annotation correctly
> is the better idea?
If the spinlock is protecting the data, then just add the spinlock
to the rcu_dereference_check() as shown above.
Thanx, Paul
next prev parent reply other threads:[~2012-05-15 14:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-15 4:41 suspicious RCU usage in security/selinux/netnode.c Dave Jones
2012-05-15 5:16 ` Paul E. McKenney
2012-05-15 14:24 ` Eric Paris
2012-05-15 14:46 ` Paul E. McKenney [this message]
2012-05-15 14:52 ` Eric Paris
2012-05-15 15:12 ` Paul Moore
2012-05-15 15:37 ` Paul E. McKenney
2012-05-15 18:35 ` Paul Moore
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=20120515144658.GC2461@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=davej@redhat.com \
--cc=eparis@parisplace.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
/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