block: fix locking in bdev_del_partition
authorChristoph Hellwig <hch@lst.de>
Tue, 1 Sep 2020 09:59:41 +0000 (11:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Sep 2020 17:14:20 +0000 (19:14 +0200)
commit692d0626557451c4b557397f20b7394b612d0289
treee8950482115f375068561e75840572dfc40cd0ce
parentbbb1dc4431b0c37eca621a2d618c8d3c1276e5a9
block: fix locking in bdev_del_partition

[ Upstream commit 08fc1ab6d748ab1a690fd483f41e2938984ce353 ]

We need to hold the whole device bd_mutex to protect against
other thread concurrently deleting out partition before we get
to it, and thus causing a use after free.

Fixes: cddae808aeb7 ("block: pass a hd_struct to delete_partition")
Reported-by: syzbot+6448f3c229bc52b82f69@syzkaller.appspotmail.com
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/partitions/core.c