]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix match incorrectly in dev_args_match_device
authorLiu Shixin <liushixin2@huawei.com>
Thu, 3 Nov 2022 08:33:01 +0000 (16:33 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 7 Nov 2022 13:30:45 +0000 (14:30 +0100)
commitd36cca19f2477ec0f112e9ee972db82de2d2d235
tree18584038243e4dc1fbced7f1d327b1b91afe04a4
parent6fa9c392640785f81d574b8143dd3a10696fb0e5
btrfs: fix match incorrectly in dev_args_match_device

syzkaller found a failed assertion:

  assertion failed: (args->devid != (u64)-1) || args->missing, in fs/btrfs/volumes.c:6921

This can be triggered when we set devid to (u64)-1 by ioctl. In this
case, the match of devid will be skipped and the match of device may
succeed incorrectly.

Patch 0d33b5b39854 introduced this function which is used to match device.
This function contains two matching scenarios, we can distinguish them by
checking the value of args->missing rather than check whether args->devid
and args->uuid is default value.

Reported-by: syzbot+031687116258450f9853@syzkaller.appspotmail.com
Fixes: 0d33b5b39854 ("btrfs: handle device lookup with btrfs_dev_lookup_args")
CC: stable@vger.kernel.org # 5.16+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c