]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 12:59:24 +0000 (13:59 +0100)
commit6607f428308cfb1d2a9877cacd6e68e64787f580
treedb5e89e861cbb5d292a6d66079186a3152a02861
parentd383a4f2707c4d379065115c777d5ac558b9e03b
btrfs: fix match incorrectly in dev_args_match_device

commit 0fca385d6ebc3cabb20f67bcf8a71f1448bdc001 upstream.

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 562d7b1512f7 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: 562d7b1512f7 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c9fe4719c662e0af17eea723cf345e37719fd3c9)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
fs/btrfs/volumes.c