linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sasha.levin@oracle.com>
To: Thomas Graf <tgraf@suug.ch>, davem@davemloft.net, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kaber@trash.net,
	paulmck@linux.vnet.ibm.com, josh@joshtriplett.org,
	challa@noironetworks.com, walpole@cs.pdx.edu,
	dev@openvswitch.org, netfilter-devel@vger.kernel.org,
	nikolay@redhat.com,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH net-next 2/3] netlink: Convert netlink_lookup() to use RCU protected hash table
Date: Mon, 04 Aug 2014 22:10:19 -0400	[thread overview]
Message-ID: <53E03D0B.3000208@oracle.com> (raw)
In-Reply-To: <a0370889bd1b1bdf097f74df7017d39ae845c12e.1406971567.git.tgraf@suug.ch>

On 08/02/2014 05:47 AM, Thomas Graf wrote:
>  static void *netlink_seq_start(struct seq_file *seq, loff_t *pos)
> -	__acquires(nl_table_lock)
>  {
> -	read_lock(&nl_table_lock);
> +	rcu_read_lock();
>  	return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : SEQ_START_TOKEN;
>  }

I'm not sure how you expect this code to work. You're replacing a local lock
with a RCU critical section. Imagine you're doing spin_lock() and just going
back to userspace.

It's quite easy to trigger this issue:

[  531.479773] ===============================
[  531.482951] [ INFO: suspicious RCU usage. ]
[  531.485512] 3.16.0-next-20140804-sasha-00029-gcb12d07 #995 Not tainted
[  531.489198] -------------------------------
[  531.491518] net/netlink/af_netlink.c:2953 suspicious rcu_dereference_protected() usage!
[  531.495781]
[  531.495781] other info that might help us debug this:
[  531.495781]
[  531.499094]
[  531.499094] rcu_scheduler_active = 1, debug_locks = 1
[  531.502685] 3 locks held by trinity-c490/9673:
[  531.505179] #0: (&f->f_pos_lock){+.+.+.}, at: __fdget_pos (fs/file.c:714)
[  531.510057] #1: (&p->lock){+.+.+.}, at: seq_lseek (fs/seq_file.c:322)
[  531.514819] #2: (rcu_read_lock){......}, at: netlink_seq_start (net/netlink/af_netlink.c:2923)
[  531.517956]
[  531.517956] stack backtrace:
[  531.519054] CPU: 7 PID: 9673 Comm: cat Not tainted 3.16.0-next-20140804-sasha-00029-gcb12d07 #995
[  531.521526]  0000000000000000 00000000917b9e45 ffff881efe493e20 ffffffffa55825a1
[  531.523616]  ffff881efebeb000 ffff881efe493e50 ffffffffa21d3a75 ffffffffa81ce2c0
[  531.527426]  0000000000000002 ffff8807cb581d90 ffff880fa3da8000 ffff881efe493ea0
[  531.532068] Call Trace:
[  531.533595] dump_stack (lib/dump_stack.c:52)
[  531.536398] lockdep_rcu_suspicious (kernel/locking/lockdep.c:4259)
[  531.537934] netlink_seq_next (net/netlink/af_netlink.c:2953 (discriminator 5))
[  531.539355] traverse (fs/seq_file.c:142)
[  531.541241] ? mutex_lock_nested (./arch/x86/include/asm/preempt.h:98 kernel/locking/mutex.c:567 kernel/locking/mutex.c:584)
[  531.544797] seq_lseek (fs/seq_file.c:331 (discriminator 1))
[  531.547485] proc_reg_llseek (fs/proc/inode.c:197)
[  531.549904] SyS_lseek (fs/read_write.c:264 fs/read_write.c:289 fs/read_write.c:280)
[  531.552190] tracesys (arch/x86/kernel/entry_64.S:541)

I'd suggest testing any RCU related patches with CONFIG_PROVE_RCU in the future.


Thanks,
Sasha

  parent reply	other threads:[~2014-08-05  2:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-02  9:47 [PATCH net-next v5 0/3] Lockless netlink_lookup() with new concurrent hash table Thomas Graf
2014-08-02  9:47 ` [PATCH net-next 1/3] lib: Resizable, Scalable, Concurrent Hash Table Thomas Graf
2014-08-02 10:32   ` Nikolay Aleksandrov
2014-08-02  9:47 ` [PATCH net-next 2/3] netlink: Convert netlink_lookup() to use RCU protected hash table Thomas Graf
2014-08-02 10:44   ` Nikolay Aleksandrov
2014-08-05  2:10   ` Sasha Levin [this message]
2014-08-05  2:58     ` David Miller
2014-08-05  5:50       ` Eric Dumazet
2014-08-05  5:58         ` David Miller
2014-08-02  9:47 ` [PATCH net-next 3/3] nftables: Convert nft_hash to use generic rhashtable Thomas Graf
2014-08-02 10:56   ` Nikolay Aleksandrov
2014-08-03  2:53 ` [PATCH net-next v5 0/3] Lockless netlink_lookup() with new concurrent hash table David Miller
  -- strict thread matches above, loose matches on Subject: below --
2014-08-01 11:58 [PATCH net-next v4 " Thomas Graf
2014-08-01 11:58 ` [PATCH net-next 2/3] netlink: Convert netlink_lookup() to use RCU protected " Thomas Graf
2014-08-01 14:51   ` Nikolay Aleksandrov
2014-08-01 15:15     ` Thomas Graf
2014-08-01 15:20       ` Nikolay Aleksandrov
2014-08-01  8:51 [PATCH net-next v3 0/3] Lockless netlink_lookup() with new concurrent " Thomas Graf
2014-08-01  8:51 ` [PATCH net-next 2/3] netlink: Convert netlink_lookup() to use RCU protected " Thomas Graf
2014-07-31 22:56 [PATCH v2 0/3 net-next] Lockless netlink_lookup() with new concurrent " Thomas Graf
2014-07-31 22:56 ` [PATCH net-next 2/3] netlink: Convert netlink_lookup() to use RCU protected " Thomas Graf

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=53E03D0B.3000208@oracle.com \
    --to=sasha.levin@oracle.com \
    --cc=challa@noironetworks.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=josh@joshtriplett.org \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=nikolay@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tgraf@suug.ch \
    --cc=walpole@cs.pdx.edu \
    /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).