Skip to content

Commit 4f4374a

Browse files
Miklos Szeredigregkh
authored andcommitted
vfs: fix freeze protection in mnt_want_write_file() for overlayfs
[ Upstream commit a6795a5 ] The underlying real file used by overlayfs still contains the overlay path. This results in mnt_want_write_file() calls by the filesystem getting freeze protection on the wrong inode (the overlayfs one instead of the real one). Fix by using file_inode(file)->i_sb instead of file->f_path.mnt->mnt_sb. Reported-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b888dba commit 4f4374a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/namespace.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,10 @@ int mnt_want_write_file_path(struct file *file)
446446
{
447447
int ret;
448448

449-
sb_start_write(file->f_path.mnt->mnt_sb);
449+
sb_start_write(file_inode(file)->i_sb);
450450
ret = __mnt_want_write_file(file);
451451
if (ret)
452-
sb_end_write(file->f_path.mnt->mnt_sb);
452+
sb_end_write(file_inode(file)->i_sb);
453453
return ret;
454454
}
455455

@@ -540,7 +540,8 @@ void __mnt_drop_write_file(struct file *file)
540540

541541
void mnt_drop_write_file_path(struct file *file)
542542
{
543-
mnt_drop_write(file->f_path.mnt);
543+
__mnt_drop_write_file(file);
544+
sb_end_write(file_inode(file)->i_sb);
544545
}
545546

546547
void mnt_drop_write_file(struct file *file)

0 commit comments

Comments
 (0)