* [BUG REPORT] Incorrect adaptation of 7e49538288e5 ("loop: Avoid updating block size under exclusive owner") for stable 6.6
@ 2025-09-24 2:36 yangerkun
2025-09-29 13:28 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: yangerkun @ 2025-09-24 2:36 UTC (permalink / raw)
To: Sasha Levin, linux-stable, gregkh, Jan Kara; +Cc: yangerkun
Error path for blk_validate_block_size is wrong, we should goto unlock,
or lo_mutex won't be release, and bdev will keep claimed.
...
-static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
+static int loop_set_block_size(struct loop_device *lo, blk_mode_t mode,
+ struct block_device *bdev, unsigned long arg)
{
int err = 0;
- if (lo->lo_state != Lo_bound)
- return -ENXIO;
+ /*
+ * If we don't hold exclusive handle for the device, upgrade to it
+ * here to avoid changing device under exclusive owner.
+ */
+ if (!(mode & BLK_OPEN_EXCL)) {
+ err = bd_prepare_to_claim(bdev, loop_set_block_size, NULL);
+ if (err)
+ return err;
+ }
+
+ err = mutex_lock_killable(&lo->lo_mutex);
+ if (err)
+ goto abort_claim;
+
+ if (lo->lo_state != Lo_bound) {
+ err = -ENXIO;
+ goto unlock;
+ }
err = blk_validate_block_size(arg);
if (err)
return err;
^^^^^^^^^^^^^
should goto unlock
if (lo->lo_queue->limits.logical_block_size == arg)
- return 0;
+ goto unlock;
sync_blockdev(lo->lo_device);
invalidate_bdev(lo->lo_device);
blk_mq_freeze_queue(lo->lo_queue);
blk_queue_logical_block_size(lo->lo_queue, arg);
blk_queue_physical_block_size(lo->lo_queue, arg);
blk_queue_io_min(lo->lo_queue, arg);
loop_update_dio(lo);
blk_mq_unfreeze_queue(lo->lo_queue);
+unlock:
+ mutex_unlock(&lo->lo_mutex);
+abort_claim:
+ if (!(mode & BLK_OPEN_EXCL))
+ bd_abort_claiming(bdev, loop_set_block_size);
return err;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG REPORT] Incorrect adaptation of 7e49538288e5 ("loop: Avoid updating block size under exclusive owner") for stable 6.6
2025-09-24 2:36 [BUG REPORT] Incorrect adaptation of 7e49538288e5 ("loop: Avoid updating block size under exclusive owner") for stable 6.6 yangerkun
@ 2025-09-29 13:28 ` Greg KH
2025-09-30 3:42 ` yangerkun
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2025-09-29 13:28 UTC (permalink / raw)
To: yangerkun; +Cc: Sasha Levin, linux-stable, Jan Kara
On Wed, Sep 24, 2025 at 10:36:19AM +0800, yangerkun wrote:
> Error path for blk_validate_block_size is wrong, we should goto unlock, or
> lo_mutex won't be release, and bdev will keep claimed.
Can you provide a working patch we can apply?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG REPORT] Incorrect adaptation of 7e49538288e5 ("loop: Avoid updating block size under exclusive owner") for stable 6.6
2025-09-29 13:28 ` Greg KH
@ 2025-09-30 3:42 ` yangerkun
0 siblings, 0 replies; 3+ messages in thread
From: yangerkun @ 2025-09-30 3:42 UTC (permalink / raw)
To: Greg KH; +Cc: Sasha Levin, linux-stable, Jan Kara, zhengqixing
在 2025/9/29 21:28, Greg KH 写道:
> On Wed, Sep 24, 2025 at 10:36:19AM +0800, yangerkun wrote:
>> Error path for blk_validate_block_size is wrong, we should goto unlock, or
>> lo_mutex won't be release, and bdev will keep claimed.
>
> Can you provide a working patch we can apply?
My colleague Zheng Qixing has already made the correct adaptation, and
she might release it in a week (we are about to start the National Day
holiday).
>
> thanks,
>
> greg k-h
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-30 3:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 2:36 [BUG REPORT] Incorrect adaptation of 7e49538288e5 ("loop: Avoid updating block size under exclusive owner") for stable 6.6 yangerkun
2025-09-29 13:28 ` Greg KH
2025-09-30 3:42 ` yangerkun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox