mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 09:33:31 +02:00
f2fs: fix freezing filesystem during resize
Using FREEZE_HOLDER_USERSPACE has two consequences:
(1) If userspace freezes the filesystem after mnt_drop_write_file() but
before freeze_super() was called filesystem resizing will fail
because the freeze isn't marked as nestable.
(2) If the kernel has successfully frozen the filesystem via
FREEZE_HOLDER_USERSPACE userspace can simply undo it by using the
FITHAW ioctl.
Fix both issues by using FREEZE_HOLDER_KERNEL. It will nest with
FREEZE_HOLDER_USERSPACE and cannot be undone by userspace.
And it is the correct thing to do because the kernel temporarily freezes
the filesystem.
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
05b158d4fd
commit
1afe9e7da8
|
|
@ -2271,12 +2271,12 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
err = freeze_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
|
||||
err = freeze_super(sbi->sb, FREEZE_HOLDER_KERNEL, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (f2fs_readonly(sbi->sb)) {
|
||||
err = thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
|
||||
err = thaw_super(sbi->sb, FREEZE_HOLDER_KERNEL, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
return -EROFS;
|
||||
|
|
@ -2333,6 +2333,6 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
|
|||
out_err:
|
||||
f2fs_up_write(&sbi->cp_global_sem);
|
||||
f2fs_up_write(&sbi->gc_lock);
|
||||
thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
|
||||
thaw_super(sbi->sb, FREEZE_HOLDER_KERNEL, NULL);
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user