Fix another RCU lockdep warning (cgroups).

This commit is contained in:
Dave Jones 2010-09-15 16:12:01 -04:00
parent cb6f3ab735
commit 291833d307
2 changed files with 52 additions and 0 deletions

View File

@ -729,6 +729,7 @@ Patch12080: kprobes-x86-fix-kprobes-to-skip-prefixes-correctly.patch
# rhbz #622149
Patch12085: fix-rcu_deref_check-warning.patch
Patch12086: linux-2.6-cgroups-rcu.patch
# rhbz #513530
Patch12090: dell-wmi-add-support-for-eject-key-studio-1555.patch
@ -1366,6 +1367,7 @@ ApplyPatch kprobes-x86-fix-kprobes-to-skip-prefixes-correctly.patch
# bz 622149
ApplyPatch fix-rcu_deref_check-warning.patch
ApplyPatch linux-2.6-cgroups-rcu.patch
# bz 513530
ApplyPatch dell-wmi-add-support-for-eject-key-studio-1555.patch
@ -1972,6 +1974,9 @@ fi
# and build.
%changelog
* Wed Sep 15 2010 Dave Jones <davej@redhat.com>
- Fix another RCU lockdep warning (cgroups).
* Wed Sep 15 2010 Hans de Goede <hdegoede@redhat.com>
- virtio_console: Fix poll/select blocking even though there is data to read

View File

@ -0,0 +1,47 @@
Message-ID: <4C805293.1020305@cn.fujitsu.com>
Date: Fri, 03 Sep 2010 09:42:43 +0800
From: Li Zefan <lizf@cn.fujitsu.com>
To: David Miller <davem@davemloft.net>
CC: Herbert Xu <herbert@gondor.hengli.com.au>, Dave Jones <davej@redhat.com>,
netdev <netdev@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>, Paul Menage <menage@google.com>
Subject: [PATCH v2] cls_cgroup: Fix rcu lockdep warning
Dave reported an rcu lockdep warning on 2.6.35.4 kernel
task->cgroups and task->cgroups->subsys[i] are protected by RCU.
So we avoid accessing invalid pointers here. This might happen,
for example, when you are deref-ing those pointers while someone
move @task from one cgroup to another.
Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
include/net/cls_cgroup.h | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index dd1fdb8..a4dc5b0 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h
@@ -27,11 +27,17 @@ struct cgroup_cls_state
#ifdef CONFIG_NET_CLS_CGROUP
static inline u32 task_cls_classid(struct task_struct *p)
{
+ int classid;
+
if (in_interrupt())
return 0;
- return container_of(task_subsys_state(p, net_cls_subsys_id),
- struct cgroup_cls_state, css)->classid;
+ rcu_read_lock();
+ classid = container_of(task_subsys_state(p, net_cls_subsys_id),
+ struct cgroup_cls_state, css)->classid;
+ rcu_read_unlock();
+
+ return classid;
}
#else
extern int net_cls_subsys_id;