[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94abea02-0c6f-cd0b-5aa4-fef08f9b2ab8@acm.org>
Date: Mon, 22 Mar 2021 15:21:19 -0700
From: Bart Van Assche <bvanassche@....org>
To: Christoph Hellwig <hch@....de>,
syzbot <syzbot+8fede7e30c7cee0de139@...kaller.appspotmail.com>
Cc: axboe@...nel.dk, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org, syzkaller-bugs@...glegroups.com,
tj@...nel.org
Subject: Re: [syzbot] KASAN: use-after-free Read in disk_part_iter_next (2)
On 3/22/21 12:18 AM, Christoph Hellwig wrote:
> I've been running the reproducer on a KASAN enable VM for about
> 15 minutes now, but haven't been able to reproduce it.
>
> Is there a way to inject this proposed fix into the syzbot queue?
>
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index 1a7558917c47d6..f5d5872b89d57e 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -288,15 +288,12 @@ struct device_type part_type = {
> void delete_partition(struct block_device *part)
> {
> xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
> - kobject_put(part->bd_holder_dir);
> - device_del(&part->bd_device);
> -
> - /*
> - * Remove the block device from the inode hash, so that it cannot be
> - * looked up any more even when openers still hold references.
> - */
> remove_inode_hash(part->bd_inode);
>
> + synchronize_rcu();
> +
> + kobject_put(part->bd_holder_dir);
> + device_del(&part->bd_device);
> put_device(&part->bd_device);
> }
Hi Christoph,
disk_part_iter_next() calls bdgrab() before returning a pointer to a
certain partition. 'part' is only freed if its reference count drops to
zero. The function that frees the partition information,
bdev_free_inode(), is invoked via call_rcu(). bdgrab() fails if the
refcount of a partition is zero. Does that mean that it is not necessary
to call synchronize_rcu() between xa_erase() and put_device()?
Thanks,
Bart.
Powered by blists - more mailing lists