Commit 5dbb6255 authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Greg Kroah-Hartman

ext4: avoid race conditions when remounting with options that change dax

[ Upstream commit 829b37b8 ]

Trying to change dax mount options when remounting could allow mount
options to be enabled for a small amount of time, and then the mount
option change would be reverted.

In the case of "mount -o remount,dax", this can cause a race where
files would temporarily treated as DAX --- and then not.

Cc: stable@kernel.org
Reported-by: syzbot+bca9799bf129256190da@syzkaller.appspotmail.com
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 051bf267
...@@ -1989,6 +1989,16 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, ...@@ -1989,6 +1989,16 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
#endif #endif
} else if (token == Opt_dax) { } else if (token == Opt_dax) {
#ifdef CONFIG_FS_DAX #ifdef CONFIG_FS_DAX
if (is_remount && test_opt(sb, DAX)) {
ext4_msg(sb, KERN_ERR, "can't mount with "
"both data=journal and dax");
return -1;
}
if (is_remount && !(sbi->s_mount_opt & EXT4_MOUNT_DAX)) {
ext4_msg(sb, KERN_ERR, "can't change "
"dax mount option while remounting");
return -1;
}
ext4_msg(sb, KERN_WARNING, ext4_msg(sb, KERN_WARNING,
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
sbi->s_mount_opt |= m->mount_opt; sbi->s_mount_opt |= m->mount_opt;
...@@ -5274,12 +5284,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -5274,12 +5284,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
err = -EINVAL; err = -EINVAL;
goto restore_opts; goto restore_opts;
} }
if (test_opt(sb, DAX)) {
ext4_msg(sb, KERN_ERR, "can't mount with "
"both data=journal and dax");
err = -EINVAL;
goto restore_opts;
}
} else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) { } else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) {
if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
ext4_msg(sb, KERN_ERR, "can't mount with " ext4_msg(sb, KERN_ERR, "can't mount with "
...@@ -5295,12 +5299,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -5295,12 +5299,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
goto restore_opts; goto restore_opts;
} }
if ((sbi->s_mount_opt ^ old_opts.s_mount_opt) & EXT4_MOUNT_DAX) {
ext4_msg(sb, KERN_WARNING, "warning: refusing change of "
"dax flag with busy inodes while remounting");
sbi->s_mount_opt ^= EXT4_MOUNT_DAX;
}
if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
ext4_abort(sb, "Abort forced by user"); ext4_abort(sb, "Abort forced by user");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment