55d5380
From 85f4e5ec7bbb5f8d7cc023a12af39d76c05cd204 Mon Sep 17 00:00:00 2001
55d5380
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
55d5380
Date: Wed, 2 Sep 2015 17:14:33 -0700
9700819
Subject: [PATCH] security: device_cgroup: fix RCU lockdep splat
9700819
55d5380
On Wed, Sep 02, 2015 at 12:24:50PM -0400, Tejun Heo wrote:
55d5380
> cc'ing Paul.
55d5380
>
55d5380
> On Wed, Sep 02, 2015 at 08:12:28AM -0500, Felipe Balbi wrote:
55d5380
> > while booting AM437x device, the following splat
55d5380
> > triggered:
55d5380
> >
55d5380
> > [   12.005238] ===============================
55d5380
> > [   12.009749] [ INFO: suspicious RCU usage. ]
55d5380
> > [   12.014116] 4.2.0-next-20150831 #1154 Not tainted
55d5380
> > [   12.019050] -------------------------------
55d5380
> > [   12.023408] security/device_cgroup.c:405 device_cgroup:verify_new_ex called without proper synchronization!
55d5380
> ...
55d5380
> > [   12.128326] [<c0317a04>] (verify_new_ex) from [<c0317f50>] (devcgroup_access_write+0x374/0x658)
55d5380
> > [   12.137426] [<c0317f50>] (devcgroup_access_write) from [<c00d2800>] (cgroup_file_write+0x28/0x1bc)
55d5380
> > [   12.146796] [<c00d2800>] (cgroup_file_write) from [<c01f1670>] (kernfs_fop_write+0xc0/0x1b8)
55d5380
> > [   12.155620] [<c01f1670>] (kernfs_fop_write) from [<c0177c94>] (__vfs_write+0x1c/0xd8)
55d5380
> > [   12.163783] [<c0177c94>] (__vfs_write) from [<c0178594>] (vfs_write+0x90/0x16c)
55d5380
> > [   12.171426] [<c0178594>] (vfs_write) from [<c0178db4>] (SyS_write+0x44/0x9c)
55d5380
> > [   12.178806] [<c0178db4>] (SyS_write) from [<c000f680>] (ret_fast_syscall+0x0/0x1c)
55d5380
>
55d5380
> This shouldn't be happening because devcgroup_access_write() always
55d5380
> grabs devcgroup_mutex.  Looking at the log, the culprit seems to be
55d5380
> f78f5b90c4ff ("rcu: Rename rcu_lockdep_assert() to
55d5380
> RCU_LOCKDEP_WARN()").  It missed the bang for the second test while
55d5380
> inverting it, so adding rcu_read_lock() isn't the right fix here.
55d5380
>
55d5380
> Paul, can you please fix it?
9700819
55d5380
Gah!  Please see below.
9700819
55d5380
							Thanx, Paul
9700819
55d5380
------------------------------------------------------------------------
9700819
55d5380
security/device_cgroup: Fix RCU_LOCKDEP_WARN() condition
55d5380
55d5380
f78f5b90c4ff ("rcu: Rename rcu_lockdep_assert() to RCU_LOCKDEP_WARN()")
55d5380
introduced a bug by incorrectly inverting the condition when moving from
55d5380
rcu_lockdep_assert() to RCU_LOCKDEP_WARN().  This commit therefore fixes
55d5380
the inversion.
55d5380
55d5380
Reported-by: Felipe Balbi <balbi@ti.com>
55d5380
Reported-by: Tejun Heo <tj@kernel.org>
55d5380
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
55d5380
Cc: Serge Hallyn <serge@hallyn.com>
9700819
---
55d5380
 security/device_cgroup.c | 2 +-
55d5380
 1 file changed, 1 insertion(+), 1 deletion(-)
9700819
9700819
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
55d5380
index 73455089feef..03c1652c9a1f 100644
9700819
--- a/security/device_cgroup.c
9700819
+++ b/security/device_cgroup.c
55d5380
@@ -401,7 +401,7 @@ static bool verify_new_ex(struct dev_cgroup *dev_cgroup,
55d5380
 	bool match = false;
9700819
 
55d5380
 	RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&
55d5380
-			 lockdep_is_held(&devcgroup_mutex),
55d5380
+			 !lockdep_is_held(&devcgroup_mutex),
55d5380
 			 "device_cgroup:verify_new_ex called without proper synchronization");
9700819
 
55d5380
 	if (dev_cgroup->behavior == DEVCG_DEFAULT_ALLOW) {
9700819
-- 
9700819
2.4.3
9700819