public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: James Chapman <jchapman@katalix•com>
To: Eric Dumazet <eric.dumazet@gmail•com>
Cc: netdev@vger•kernel.org
Subject: Re: [PATCH net-next-2.6 v4 10/14] l2tp: Convert rwlock to RCU
Date: Wed, 21 Apr 2010 14:53:58 +0100	[thread overview]
Message-ID: <4BCF0376.9010504@katalix.com> (raw)
In-Reply-To: <1271782553.7895.62.camel@edumazet-laptop>

Eric Dumazet wrote:
> Hi James
> 
> I started a while ago patching l2tp but I wont be able to finish and
> test the thing...
> 
> There is a fundamental problem with this kind of construct :
> (this was wrong even better your RCU conversion)
> 
> rcu_read_lock_bh()
> hlist_for_each_entry_rcu(session, walk, session_list, global_hlist) {
> 	if (session->session_id == session_id) {
> 		rcu_read_unlock_bh();
> 		return session;
> 	}
> }
> rcu_read_unlock_bh();
> 
> 
> While the lookup _is_ protected, the result is not.
> 
> As soon as you call rcu_read_unlock_bh(); and before the "return
> session;", current thread could be preempted and an other thread frees
> session under first thread. Unexpected things can then happen.
> 
> Therefore, you need either to :
> 
> 1) Take a refcount on session (or tunnel) before the return
> 2) Or move the rcu_read_lock_bh()/rcu_read_unlock_bh() at callers.
> 3) Or all callers use a stronger lock. But then, why use RCU ;)
> 
> Here is a preliminary patch, obviously not finished, nor compiled, nor
> tested, to give possible ways to handle this problem.
> 
> (I added the ref parameter to make sure to change function signatures,
> maybe its not necessary and we should always take references)

Thanks Eric. I'll take a look at this.

-- 
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development


  reply	other threads:[~2010-04-21 13:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-02 16:18 [PATCH net-next-2.6 v4 00/14] l2tp: Introduce L2TPv3 support James Chapman
2010-04-02 16:18 ` [PATCH net-next-2.6 v4 01/14] l2tp: Relocate pppol2tp driver to new net/l2tp directory James Chapman
2010-04-02 16:18 ` [PATCH net-next-2.6 v4 02/14] l2tp: Split pppol2tp patch into separate l2tp and ppp parts James Chapman
2010-04-02 16:18 ` [PATCH net-next-2.6 v4 03/14] ppp: Add ppp_dev_name() exported function James Chapman
2010-04-02 16:18 ` [PATCH net-next-2.6 v4 04/14] l2tp: Add ppp device name to L2TP ppp session data James Chapman
2010-04-02 16:18 ` [PATCH net-next-2.6 v4 05/14] l2tp: Add L2TPv3 protocol support James Chapman
2010-04-02 16:18 ` [PATCH net-next-2.6 v4 06/14] l2tp: Update PPP-over-L2TP driver to work over L2TPv3 James Chapman
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 07/14] l2tp: Add L2TPv3 IP encapsulation (no UDP) support James Chapman
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 08/14] netlink: Export genl_lock() API for use by modules James Chapman
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 09/14] l2tp: Add netlink control API for L2TP James Chapman
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 10/14] l2tp: Convert rwlock to RCU James Chapman
2010-04-20 16:55   ` Eric Dumazet
2010-04-21 13:53     ` James Chapman [this message]
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 11/14] l2tp: Add L2TP ethernet pseudowire support James Chapman
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 12/14] l2tp: Add debugfs files for dumping l2tp debug info James Chapman
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 13/14] l2tp: Add support for static unmanaged L2TPv3 tunnels James Chapman
2010-04-02 16:19 ` [PATCH net-next-2.6 v4 14/14] l2tp: Update documentation James Chapman
2010-04-03 21:25 ` [PATCH net-next-2.6 v4 00/14] l2tp: Introduce L2TPv3 support David Miller
2010-04-03 22:04   ` David Miller
2010-04-04  7:54   ` Eric Dumazet
2010-04-04  8:02     ` David Miller
2010-04-04  8:14       ` 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=4BCF0376.9010504@katalix.com \
    --to=jchapman@katalix$(echo .)com \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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