From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: "Cristian Rodríguez" <crrodriguez@opensuse.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: include/linux/cgroup.h:566 suspicious rcu_dereference_check() usage!
Date: Mon, 8 Oct 2012 12:49:21 -0700 [thread overview]
Message-ID: <20121008194921.GF2453@linux.vnet.ibm.com> (raw)
In-Reply-To: <506F649F.4050109@opensuse.org>
On Fri, Oct 05, 2012 at 07:52:15PM -0300, Cristian Rodríguez wrote:
> Hi:
> I am getting this in the current linus tree.
>
> [ 0.408781] ===============================
> [ 0.408783] [ INFO: suspicious RCU usage. ]
> [ 0.408786] 3.6.0-canneverbe-07124-g5f3d2f2 #18 Not tainted
> [ 0.408789] -------------------------------
> [ 0.408791] include/linux/cgroup.h:566 suspicious
> rcu_dereference_check() usage!
> [ 0.408795]
> [ 0.408795] other info that might help us debug this:
> [ 0.408795]
> [ 0.408799]
> [ 0.408799] rcu_scheduler_active = 1, debug_locks = 0
> [ 0.408802] 2 locks held by kdevtmpfs/49:
> [ 0.408804] #0: (sb_writers){.+.+.+}, at: [<ffffffff8119a2ef>]
> mnt_want_write+0x1f/0x50
> [ 0.408814] #1: (&sb->s_type->i_mutex_key#3/1){+.+.+.}, at:
> [<ffffffff811857cf>] kern_path_create+0x7f/0x170
> [ 0.408822]
> [ 0.408822] stack backtrace:
> [ 0.408825] Pid: 49, comm: kdevtmpfs Not tainted
> 3.6.0-canneverbe-07124-g5f3d2f2 #18
> [ 0.408829] Call Trace:
> [ 0.408834] [<ffffffff8109fabd>] lockdep_rcu_suspicious+0xfd/0x130
> [ 0.408838] [<ffffffff812a876d>] devcgroup_inode_mknod+0x18d/0x230
> [ 0.408843] [<ffffffff8126f923>] ? security_capable+0x13/0x20
> [ 0.408848] [<ffffffff8104a06f>] ? ns_capable+0x3f/0x80
> [ 0.408851] [<ffffffff81186c09>] vfs_mknod+0x79/0x140
> [ 0.408856] [<ffffffff813a6df2>] handle_create.isra.2+0x72/0x200
> [ 0.408860] [<ffffffff813a702c>] ? devtmpfsd+0xac/0x140
> [ 0.408863] [<ffffffff813a7094>] devtmpfsd+0x114/0x140
> [ 0.408867] [<ffffffff813a6f80>] ? handle_create.isra.2+0x200/0x200
> [ 0.408871] [<ffffffff81064de6>] kthread+0xd6/0xe0
> [ 0.408877] [<ffffffff81578cb4>] kernel_thread_helper+0x4/0x10
> [ 0.408881] [<ffffffff8156f85c>] ? retint_restore_args+0xe/0xe
> [ 0.408885] [<ffffffff81064d10>] ? flush_kthread_work+0x190/0x190
> [ 0.408889] [<ffffffff81578cb0>] ? gs_change+0xb/0xb
>
>
> Hope someone can take a look at it.
It looks to me like commit #ad676077 (device_cgroup: convert device_cgroup
internally to policy + exceptions) removed a needed rcu_read_lock().
See below for an untested patch restoring rcu_read_lock().
Thanx, Paul
------------------------------------------------------------------------
device_cgroup: Restore rcu_read_lock() protection to devcgroup_inode_mknod()
Commit ad676077 (device_cgroup: convert device_cgroup internally to
policy + exceptions) restructured devcgroup_inode_mknod(), removing
rcu_read_lock() in the process. However, RCU read-side protection
is required by the call to task_devcgroup(), so this commit restores
the rcu_read_lock() and rcu_read_unlock().
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 44dfc41..c686110 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -576,9 +576,12 @@ int __devcgroup_inode_permission(struct inode *inode, int mask)
int devcgroup_inode_mknod(int mode, dev_t dev)
{
- struct dev_cgroup *dev_cgroup = task_devcgroup(current);
+ struct dev_cgroup *dev_cgroup;
+ int ret;
short type;
+ rcu_read_lock();
+ dev_cgroup = task_devcgroup(current);
if (!S_ISBLK(mode) && !S_ISCHR(mode))
return 0;
@@ -587,7 +590,9 @@ int devcgroup_inode_mknod(int mode, dev_t dev)
else
type = DEV_CHAR;
- return __devcgroup_check_permission(dev_cgroup, type, MAJOR(dev),
+ ret = __devcgroup_check_permission(dev_cgroup, type, MAJOR(dev),
MINOR(dev), ACC_MKNOD);
+ rcu_read_unlock();
+ return ret;
}
next prev parent reply other threads:[~2012-10-08 19:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-05 22:52 include/linux/cgroup.h:566 suspicious rcu_dereference_check() usage! Cristian Rodríguez
2012-10-08 19:49 ` Paul E. McKenney [this message]
2012-10-10 1:08 ` Sergey Senozhatsky
2012-10-10 3:25 ` Paul E. McKenney
2012-10-10 23:20 ` Sergey Senozhatsky
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=20121008194921.GF2453@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=crrodriguez@opensuse.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.