device_cgroup: fix RCU usage
authorTejun Heo <tj@kernel.org>
Tue, 6 Nov 2012 17:17:37 +0000 (09:17 -0800)
committerTejun Heo <tj@kernel.org>
Tue, 6 Nov 2012 20:25:51 +0000 (12:25 -0800)
commit201e72acb2d3821e2de9ce6091e98859c316b29a
tree01e47038346474d659714151b8209673c11f330a
parent64e104771351d365e51e588a0e9a656ae6ed2f50
device_cgroup: fix RCU usage

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: stable@vger.kernel.org
Cc: Aristeu Rozanski <aris@redhat.com>
Cc: Li Zefan <lizefan@huawei.com>
security/device_cgroup.c