Linux block layer
 help / color / mirror / Atom feed
* [PATCH] block: Fixup condition detecting exclusive opener during partition rescan
@ 2022-12-01 11:44 Jan Kara
  2022-12-01 14:45 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2022-12-01 11:44 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Christoph Hellwig, linux-block, Jan Kara, stable

The condition detecting whether somebody else has the device exclusively
open in disk_scan_partitions() has a brownpaper bag bug. It triggers also
when nobody has the device exclusively open and we are coming from
BLKRRPART path. Interestingly this didn't have any adverse effects
during testing because tools update kernel's notion of the partition
table using ioctls and don't rely on BLKRRPART. Fix the bug before
somebody trips over it.

Fixes: 8d67fc20caf8 ("block: Do not reread partition table on exclusively open device")
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
 block/genhd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/genhd.c b/block/genhd.c
index 012529d36f5b..29fb2c98b401 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -367,7 +367,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode, void *owner)
 	if (disk->open_partitions)
 		return -EBUSY;
 	/* Someone else has bdev exclusively open? */
-	if (disk->part0->bd_holder != owner)
+	if (disk->part0->bd_holder && disk->part0->bd_holder != owner)
 		return -EBUSY;
 
 	set_bit(GD_NEED_PART_SCAN, &disk->state);
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-01 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-01 11:44 [PATCH] block: Fixup condition detecting exclusive opener during partition rescan Jan Kara
2022-12-01 14:45 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox