• Jiri Slaby's avatar
    cgroup: fix invalid rcu dereference · 8c9506d1
    Jiri Slaby authored
    Commit ad676077 ("device_cgroup: convert device_cgroup internally to
    policy + exceptions") removed rcu locks which are needed in
    task_devcgroup called in this chain:
    
      devcgroup_inode_mknod OR __devcgroup_inode_permission ->
        __devcgroup_inode_permission ->
          task_devcgroup ->
            task_subsys_state ->
              task_subsys_state_check.
    
    Change the code so that task_devcgroup is safely called with rcu read
    lock held.
    
      ===============================
      [ INFO: suspicious RCU usage. ]
      3.6.0-rc5-next-20120913+ #42 Not tainted
      -------------------------------
      include/linux/cgroup.h:553 suspicious rcu_dereference_check() usage!
    
      other info that might help us debug this:
    
      rcu_scheduler_active = 1, debug_locks = 0
      2 locks held by kdevtmpfs/23:
       #0:  (sb_writers){.+.+.+}, at: [<ffffffff8116873f>]
      mnt_want_write+0x1f/0x50
       #1:  (&sb->s_type->i_mutex_key#3/1){+.+.+.}, at: [<ffffffff811558af>]
      kern_path_create+0x7f/0x170
    
      stack backtrace:
      Pid: 23, comm: kdevtmpfs Not tainted 3.6.0-rc5-next-20120913+ #42
      Call Trace:
        lockdep_rcu_suspicious+0xfd/0x130
        devcgroup_inode_mknod+0x19d/0x240
        vfs_mknod+0x71/0xf0
        handle_create.isra.2+0x72/0x200
        devtmpfsd+0x114/0x140
        ? handle_create.isra.2+0x200/0x200
        kthread+0xd6/0xe0
        kernel_thread_helper+0x4/0x10
    Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
    Cc: Dave Jones <davej@redhat.com>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Li Zefan <lizefan@huawei.com>
    Cc: James Morris <jmorris@namei.org>
    Cc: Pavel Emelyanov <xemul@openvz.org>
    Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    8c9506d1
device_cgroup.c 13.2 KB