Skip to content
  • Hou Tao's avatar
    kernfs: also call kernfs_set_rev() for positive dentry · df38d852
    Hou Tao authored
    A KMSAN warning is reported by Alexander Potapenko:
    
    BUG: KMSAN: uninit-value in kernfs_dop_revalidate+0x61f/0x840
    fs/kernfs/dir.c:1053
     kernfs_dop_revalidate+0x61f/0x840 fs/kernfs/dir.c:1053
     d_revalidate fs/namei.c:854
     lookup_dcache fs/namei.c:1522
     __lookup_hash+0x3a6/0x590 fs/namei.c:1543
     filename_create+0x312/0x7c0 fs/namei.c:3657
     do_mkdirat+0x103/0x930 fs/namei.c:3900
     __do_sys_mkdir fs/namei.c:3931
     __se_sys_mkdir fs/namei.c:3929
     __x64_sys_mkdir+0xda/0x120 fs/namei.c:3929
     do_syscall_x64 arch/x86/entry/common.c:51
    
    It seems a positive dentry in kernfs becomes a negative dentry directly
    through d_delete() in vfs_rmdir(). dentry->d_time is uninitialized
    when accessing it in kernfs_dop_revalidate(), because it is only
    initialized when created as negative dentry in kernfs_iop_lookup().
    
    The problem can be reproduced by the following command:
    
      cd /sys/fs/cgroup/pids && mkdir hi && stat hi && rmdir hi && stat hi
    
    A simple fixes seems to be init...
    df38d852