Skip to content

Commit 8e510cd

Browse files
Miklos Szeredigregkh
authored andcommitted
vfs: fix deadlock in file_remove_privs() on overlayfs
commit c1892c37769cf89c7e7ba57528ae2ccb5d153c9b upstream. file_remove_privs() is called with inode lock on file_inode(), which proceeds to calling notify_change() on file->f_path.dentry. Which triggers the WARN_ON_ONCE(!inode_is_locked(inode)) in addition to deadlocking later when ovl_setattr tries to lock the underlying inode again. Fix this mess by not mixing the layers, but doing everything on underlying dentry/inode. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Fixes: 07a2daab49c5 ("ovl: Copy up underlying inode's ->i_mode to overlay inode") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 33f9cff commit 8e510cd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

fs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,16 +1733,16 @@ static int __remove_privs(struct dentry *dentry, int kill)
17331733
*/
17341734
int file_remove_privs(struct file *file)
17351735
{
1736-
struct dentry *dentry = file->f_path.dentry;
1737-
struct inode *inode = d_inode(dentry);
1736+
struct dentry *dentry = file_dentry(file);
1737+
struct inode *inode = file_inode(file);
17381738
int kill;
17391739
int error = 0;
17401740

17411741
/* Fast path for nothing security related */
17421742
if (IS_NOSEC(inode))
17431743
return 0;
17441744

1745-
kill = file_needs_remove_privs(file);
1745+
kill = dentry_needs_remove_privs(dentry);
17461746
if (kill < 0)
17471747
return kill;
17481748
if (kill)

0 commit comments

Comments
 (0)