ovl: fix dentry leak for default_permissions
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 29 Jun 2016 06:26:59 +0000 (08:26 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 29 Jun 2016 06:26:59 +0000 (08:26 +0200)
When using the 'default_permissions' mount option, ovl_permission() on
non-directories was missing a dput(alias), resulting in "BUG Dentry still
in use".

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 8d3095f4ad47 ("ovl: default permissions")
Cc: <stable@vger.kernel.org> # v4.5+
fs/overlayfs/inode.c

index 1dbeab6cf96e54c7e43cf040ef3d909ce6fe2071..8514d692042b1f8da9f5e303c69a9aee34bb22fd 100644 (file)
@@ -121,16 +121,18 @@ int ovl_permission(struct inode *inode, int mask)
 
                err = vfs_getattr(&realpath, &stat);
                if (err)
-                       return err;
+                       goto out_dput;
 
+               err = -ESTALE;
                if ((stat.mode ^ inode->i_mode) & S_IFMT)
-                       return -ESTALE;
+                       goto out_dput;
 
                inode->i_mode = stat.mode;
                inode->i_uid = stat.uid;
                inode->i_gid = stat.gid;
 
-               return generic_permission(inode, mask);
+               err = generic_permission(inode, mask);
+               goto out_dput;
        }
 
        /* Careful in RCU walk mode */