netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sasha.levin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Thomas Graf <tgraf-G/eBtMaohhA@public.gmane.org>,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org,
	nikolay-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Paul E. McKenney"
	<paulmck-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org,
	walpole-sKt6ljEC1JY3uPMLIKxrzw@public.gmane.org
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-G/eBtMaohhA@public.gmane.org>

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:10 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 3/3] nftables: Convert nft_hash to use generic rhashtable Thomas Graf
     [not found]   ` <583cb5fc8f1bc2f47d338dfba06f514e7b89a548.1406971567.git.tgraf-G/eBtMaohhA@public.gmane.org>
2014-08-02 10:56     ` Nikolay Aleksandrov
     [not found] ` <cover.1406971567.git.tgraf-G/eBtMaohhA@public.gmane.org>
2014-08-02  9:47   ` [PATCH net-next 1/3] lib: Resizable, Scalable, Concurrent Hash Table Thomas Graf
     [not found]     ` <f7740ef7d22a334a775348caee916f1ddb3c584d.1406971567.git.tgraf-G/eBtMaohhA@public.gmane.org>
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
     [not found]     ` <a0370889bd1b1bdf097f74df7017d39ae845c12e.1406971567.git.tgraf-G/eBtMaohhA@public.gmane.org>
2014-08-02 10:44       ` Nikolay Aleksandrov
2014-08-05  2:10       ` Sasha Levin [this message]
     [not found]         ` <53E03D0B.3000208-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2014-08-05  2:58           ` David Miller
     [not found]             ` <20140804.195841.536725238366145203.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-08-05  5:50               ` Eric Dumazet
     [not found]                 ` <1407217807.3178.70.camel-XN9IlZ5yJG9HTL0Zs8A6p/gx64E7kk8eUsxypvmhUTTZJqsBc5GL+g@public.gmane.org>
2014-08-05  5:58                   ` David Miller
2014-08-03  2:53   ` [PATCH net-next v5 0/3] Lockless netlink_lookup() with new concurrent " David Miller
  -- strict thread matches above, loose matches on Subject: below --
2014-08-01 11:58 [PATCH net-next v4 " Thomas Graf
     [not found] ` <cover.1406891028.git.tgraf-G/eBtMaohhA@public.gmane.org>
2014-08-01 11:58   ` [PATCH net-next 2/3] netlink: Convert netlink_lookup() to use RCU protected " Thomas Graf
     [not found]     ` <72a64dfee4f20f2ca596df26f3e4ae543cf4c068.1406891028.git.tgraf-G/eBtMaohhA@public.gmane.org>
2014-08-01 14:51       ` Nikolay Aleksandrov
     [not found]         ` <53DBA976.8030103-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-08-01 15:15           ` Thomas Graf
     [not found]             ` <20140801151527.GF7331-FZi0V3Vbi30CUdFEqe4BF2D2FQJk+8+b@public.gmane.org>
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
     [not found] ` <cover.1406882738.git.tgraf-G/eBtMaohhA@public.gmane.org>
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
     [not found] ` <cover.1406846586.git.tgraf-G/eBtMaohhA@public.gmane.org>
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-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
    --cc=josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org \
    --cc=kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nikolay-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=paulmck-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=tgraf-G/eBtMaohhA@public.gmane.org \
    --cc=walpole-sKt6ljEC1JY3uPMLIKxrzw@public.gmane.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).