lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 12 Aug 2021 12:42:38 +0300
From:   Pavel Skripkin <paskripkin@...il.com>
To:     josef@...icpanda.com, axboe@...nel.dk
Cc:     hch@....de, linux-block@...r.kernel.org, nbd@...er.debian.org,
        linux-kernel@...r.kernel.org,
        syzbot+9937dc42271cd87d4b98@...kaller.appspotmail.com
Subject: Re: [PATCH] block: nbd: add sanity check for first_minor

On 8/12/21 12:15 PM, Pavel Skripkin wrote:
> Syzbot hit WARNING in internal_create_group(). The problem was in
> too big disk->first_minor.
> 
> disk->first_minor is initialized by value, which comes from userspace
> and there wasn't any sanity checks about value correctness. It can cause
> duplicate creation of sysfs files/links, because disk->first_minor will
> be passed to MKDEV() which causes truncation to byte. Since maximum
> minor value is 0xff, let's check if first_minor is correct minor number.
> 
> NOTE: the root case of the reported warning was in wrong error handling
> in register_disk(), but we can avoid passing knowingly wrong values to
> sysfs API, because sysfs error messages can confuse users. For example:
> user passed 1048576 as index, but sysfs complains about duplicate
> creation of /dev/block/43:0. It's not obvious how 1048576 becomes 0.
> Log and reproducer for above example can be found on syzkaller bug
> report page.
> 
> Link: https://syzkaller.appspot.com/bug?id=03c2ae9146416edf811958d5fd7acfab75b143d1
> Fixes: b0d9111a2d53 ("nbd: use an idr to keep track of nbd devices")
> Reported-by: syzbot+9937dc42271cd87d4b98@...kaller.appspotmail.com
> Signed-off-by: Pavel Skripkin <paskripkin@...il.com>
> ---
>   drivers/block/nbd.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index c38317979f74..600e9bab5d43 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1725,7 +1725,17 @@ static int nbd_dev_add(int index)
>   	refcount_set(&nbd->refs, 1);
>   	INIT_LIST_HEAD(&nbd->list);
>   	disk->major = NBD_MAJOR;
> +
> +	/* Too big first_minor can cause duplicate creation of
> +	 * sysfs files/links, since first_minor will be truncated to
> +	 * byte in __device_add_disk().
> +	 */
>   	disk->first_minor = index << part_shift;
> +	if (disk->first_minor > 0xff) {
> +		err = -EINVAL;
> +		goto out_free_idr;
> +	}
> +
>   	disk->minors = 1 << part_shift;
>   	disk->fops = &nbd_fops;
>   	disk->private_data = nbd;
> 

Fun thing: I got a reply to this email from
nsd-public@...ice.gov.hk, which is Hong Kong Police office email. Does 
anyone know what is going on? :) It's a bit scary...



With regards,
Pavel Skripkin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ