diff options
author | Tejun Heo <tj@kernel.org> | 2012-11-06 09:17:37 -0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2012-12-06 11:20:03 +0000 |
commit | c5ee58688baa98bc3a4f6095a1acf6fd7fd9e967 (patch) | |
tree | 246b22df83e054ef912999e82f9dae6f58acd33c /security | |
parent | 3e1fab33b18e2b10581e2e163ee74ec3d040a09a (diff) | |
download | linux-stable-c5ee58688baa98bc3a4f6095a1acf6fd7fd9e967.tar.gz linux-stable-c5ee58688baa98bc3a4f6095a1acf6fd7fd9e967.tar.bz2 linux-stable-c5ee58688baa98bc3a4f6095a1acf6fd7fd9e967.zip |
device_cgroup: fix RCU usage
commit 201e72acb2d3821e2de9ce6091e98859c316b29a upstream.
dev_cgroup->exceptions is protected with devcgroup_mutex for writes
and RCU for reads; however, RCU usage isn't correct.
* dev_exception_clean() doesn't use RCU variant of list_del() and
kfree(). The function can race with may_access() and may_access()
may end up dereferencing already freed memory. Use list_del_rcu()
and kfree_rcu() instead.
* may_access() may be called only with RCU read locked but doesn't use
RCU safe traversal over ->exceptions. Use list_for_each_entry_rcu().
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Cc: Aristeu Rozanski <aris@redhat.com>
Cc: Li Zefan <lizefan@huawei.com>
[bwh: Backported to 3.2:
- Adjust context
- Exception list is called whitelist]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'security')
-rw-r--r-- | security/device_cgroup.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 4450fbeec411..92e24bb6443e 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c @@ -202,8 +202,8 @@ static void devcgroup_destroy(struct cgroup_subsys *ss, dev_cgroup = cgroup_to_devcgroup(cgroup); list_for_each_entry_safe(wh, tmp, &dev_cgroup->whitelist, list) { - list_del(&wh->list); - kfree(wh); + list_del_rcu(&wh->list); + kfree_rcu(wh, rcu); } kfree(dev_cgroup); } @@ -278,7 +278,7 @@ static int may_access_whitelist(struct dev_cgroup *c, { struct dev_whitelist_item *whitem; - list_for_each_entry(whitem, &c->whitelist, list) { + list_for_each_entry_rcu(whitem, &c->whitelist, list) { if (whitem->type & DEV_ALL) return 1; if ((refwh->type & DEV_BLOCK) && !(whitem->type & DEV_BLOCK)) |