Re: [PATCH] btrfs: fix match incorrectly in dev_args_match_device

From: David Sterba
Date: Thu Nov 03 2022 - 12:36:27 EST


On Thu, Nov 03, 2022 at 04:33:01PM +0800, Liu Shixin wrote:
> syzkaller found an assert failed:
>
> assertion failed: (args->devid != (u64)-1) || args->missing, in fs/btrfs/volumes.c:6921
>
> This can be trigger 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 be succeed
> incorrectly.
>
> Patch 562d7b1512f7 introduced this function which is used to match device.
> This function contaions 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@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 562d7b1512f7 ("btrfs: handle device lookup with btrfs_dev_lookup_args")
> Signed-off-by: Liu Shixin <liushixin2@xxxxxxxxxx>

Added to misc-next, thanks.