From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: paul.moore@hp.com, netdev@vger.kernel.org,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH] NETLABEL: Fix an RCU warning
Date: Thu, 25 Mar 2010 14:32:20 +0100 [thread overview]
Message-ID: <1269523940.3626.37.camel@edumazet-laptop> (raw)
In-Reply-To: <6522.1269517044@redhat.com>
Le jeudi 25 mars 2010 à 11:37 +0000, David Howells a écrit :
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> > Sorry this is not the right fix.
> >
> > Fix is to change the dereference check to take into account the lock
> > owned here.
>
> Then the comments on netlbl_unlhsh_hash(), netlbl_unlhsh_search_iface(),
> netlbl_unlhsh_search_iface_def() and netlbl_unlhsh_add_iface() are all wrong,
> for all of them say:
>
> * The caller is responsible for calling the rcu_read_[un]lock()
> * functions.
>
> Furthermore, netlabel_unlhsh_add() and netlabel_unlhsh_remove() _do_ wrap the
> calls to those functions in rcu_read_lock'd sections.
Current code is probably fine.
Comments are not up to date (as many other comments BTW)
Only the dereference check is bad, as it assumes the rcu_read lock is
held.
Its not the case, we own a spinlock.
You suggest adding a surrounding rcu lock, but this surrounding lock
adds overhead on normal kernels, to correct checker warnings only.
If a mutex was protecting existing code, instead of a spinlock, then
adding rcu_read_lock() would be no correct anyway (existing code would
not be allowed to call a might_sleep function)
Please take a look at rcu_dereference_check() in :
__sk_free() (file net/core/sock.c)
__in6_dev_get() (file include/net/addrconf.h)
rcu_dereference_check_fdtable (file include/linux/fdtable.h)
task_subsys_state() (file include/linux/cgroup.h)
rcu_dereference_check_sched_domain (file kernel/sched.c)
...
for examples of proper checks.
Yes, its more difficult, but its the right thing.
next prev parent reply other threads:[~2010-03-25 13:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-25 11:06 [PATCH] NETLABEL: Fix an RCU warning David Howells
2010-03-25 11:28 ` Eric Dumazet
2010-03-25 11:37 ` David Howells
2010-03-25 13:32 ` Eric Dumazet [this message]
2010-03-25 14:10 ` Paul Moore
2010-03-29 15:24 ` Paul E. McKenney
2010-03-29 15:30 ` Paul Moore
2010-03-29 15:58 ` Paul E. McKenney
2010-03-29 20:05 ` Paul Moore
2010-03-29 20:19 ` 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=1269523940.3626.37.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=dhowells@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=paul.moore@hp.com \
--cc=paulmck@linux.vnet.ibm.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