Skip to content

Commit c1892c3

Browse files
author
Miklos Szeredi
committed
vfs: fix deadlock in file_remove_privs() on overlayfs
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 <[email protected]> Fixes: 07a2daa ("ovl: Copy up underlying inode's ->i_mode to overlay inode") Cc: <[email protected]>
1 parent 523d939 commit c1892c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,16 +1740,16 @@ static int __remove_privs(struct dentry *dentry, int kill)
17401740
*/
17411741
int file_remove_privs(struct file *file)
17421742
{
1743-
struct dentry *dentry = file->f_path.dentry;
1744-
struct inode *inode = d_inode(dentry);
1743+
struct dentry *dentry = file_dentry(file);
1744+
struct inode *inode = file_inode(file);
17451745
int kill;
17461746
int error = 0;
17471747

17481748
/* Fast path for nothing security related */
17491749
if (IS_NOSEC(inode))
17501750
return 0;
17511751

1752-
kill = file_needs_remove_privs(file);
1752+
kill = dentry_needs_remove_privs(dentry);
17531753
if (kill < 0)
17541754
return kill;
17551755
if (kill)

0 commit comments

Comments
 (0)