[GITLAB] - UPGRADE TO v12 on Wednesday the 18th of December at 11.30AM

  • Junxiao Bi's avatar
    configfs: fix race between dentry put and lookup · 7a4ca203
    Junxiao Bi authored
    commit 76ae281f6307331aa063288edb6422ae99f435f0 upstream.
    A race window in configfs, it starts from one dentry is UNHASHED and end
    before configfs_d_iput is called.  In this window, if a lookup happen,
    since the original dentry was UNHASHED, so a new dentry will be
    allocated, and then in configfs_attach_attr(), sd->s_dentry will be
    updated to the new dentry.  Then in configfs_d_iput(),
    BUG_ON(sd->s_dentry != dentry) will be triggered and system panic.
    sys_open:                     sys_close:
     ...                           fput
                                      __d_drop <--- dentry unhashed here,
                                               but sd->dentry still point
                                               to this dentry.
       configfs_attach_attr---> update sd->s_dentry
                                to new allocated dentry here.
                                         configfs_d_iput <--- BUG_ON(sd->s_dentry != dentry)
                                                         triggered here.
    To fix it, change configfs_d_iput to not update sd->s_dentry if
    sd->s_count > 2, that means there are another dentry is using the sd
    beside the one that is going to be put.  Use configfs_dirent_lock in
    configfs_attach_attr to sync with configfs_d_iput.
    With the following steps, you can reproduce the bug.
    1. enable ocfs2, this will mount configfs at /sys/kernel/config and
       fill configure in it.
    2. run the following script.
    	while [ 1 ]; do cat /sys/kernel/config/cluster/$your_cluster_name/idle_timeout_ms > /dev/null; done &
    	while [ 1 ]; do cat /sys/kernel/config/cluster/$your_cluster_name/idle_timeout_ms > /dev/null; done &
    Signed-off-by: 's avatarJunxiao Bi <junxiao.bi@oracle.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: 's avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: 's avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Last commit
Last update
Kconfig Loading commit data...
Makefile Loading commit data...
configfs_internal.h Loading commit data...
dir.c Loading commit data...
file.c Loading commit data...
inode.c Loading commit data...
item.c Loading commit data...
mount.c Loading commit data...
symlink.c Loading commit data...