• Tejun Heo's avatar
    device_cgroup: fix RCU usage · 201e72ac
    Tejun Heo authored
    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: default avatarTejun Heo <tj@kernel.org>
    Acked-by: default avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
    Cc: stable@vger.kernel.org
    Cc: Aristeu Rozanski <aris@redhat.com>
    Cc: Li Zefan <lizefan@huawei.com>
    201e72ac
device_cgroup.c 14.4 KB