Skip to content

Commit 604e668

Browse files
adam900710kdave
authored andcommitted
btrfs: scrub: reject unsupported scrub flags
Since the introduction of scrub interface, the only flag that we support is BTRFS_SCRUB_READONLY. Thus there is no sanity checks, if there are some undefined flags passed in, we just ignore them. This is problematic if we want to introduce new scrub flags, as we have no way to determine if such flags are supported. Address the problem by introducing a check for the flags, and if unsupported flags are set, return -EOPNOTSUPP to inform the user space. This check should be backported for all supported kernels before any new scrub flags are introduced. CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent f263a7c commit 604e668

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

fs/btrfs/ioctl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,6 +3161,11 @@ static long btrfs_ioctl_scrub(struct file *file, void __user *arg)
31613161
if (IS_ERR(sa))
31623162
return PTR_ERR(sa);
31633163

3164+
if (sa->flags & ~BTRFS_SCRUB_SUPPORTED_FLAGS) {
3165+
ret = -EOPNOTSUPP;
3166+
goto out;
3167+
}
3168+
31643169
if (!(sa->flags & BTRFS_SCRUB_READONLY)) {
31653170
ret = mnt_want_write_file(file);
31663171
if (ret)

include/uapi/linux/btrfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ struct btrfs_scrub_progress {
187187
};
188188

189189
#define BTRFS_SCRUB_READONLY 1
190+
#define BTRFS_SCRUB_SUPPORTED_FLAGS (BTRFS_SCRUB_READONLY)
190191
struct btrfs_ioctl_scrub_args {
191192
__u64 devid; /* in */
192193
__u64 start; /* in */

0 commit comments

Comments
 (0)