From bd67b2a5965ca7793b1a22797059aaa0ef63127f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Sep 2025 20:32:19 +0200 Subject: [PATCH] 6.6-stable patches added patches: revert-loop-avoid-updating-block-size-under-exclusive-owner.patch --- ...ing-block-size-under-exclusive-owner.patch | 108 ++++++++++++++++++ queue-6.6/series | 1 + 2 files changed, 109 insertions(+) create mode 100644 queue-6.6/revert-loop-avoid-updating-block-size-under-exclusive-owner.patch diff --git a/queue-6.6/revert-loop-avoid-updating-block-size-under-exclusive-owner.patch b/queue-6.6/revert-loop-avoid-updating-block-size-under-exclusive-owner.patch new file mode 100644 index 0000000000..a25af467cb --- /dev/null +++ b/queue-6.6/revert-loop-avoid-updating-block-size-under-exclusive-owner.patch @@ -0,0 +1,108 @@ +From ehagberg@janestreet.com Mon Sep 22 20:31:07 2025 +From: Eric Hagberg +Date: Mon, 22 Sep 2025 13:17:04 -0400 +Subject: Revert "loop: Avoid updating block size under exclusive owner" +To: gregkh@linuxfoundation.org +Cc: stable@vger.kernel.org, jack@suse.cz, Eric Hagberg +Message-ID: <20250922171704.3863333-1-ehagberg@janestreet.com> + +From: Eric Hagberg + +Revert commit ce8da5d13d8c2a7b30b2fb376a22e8eb1a70b8bb which is commit +7e49538288e523427beedd26993d446afef1a6fb upstream. + +This reverts commit ce8da5d13d8c ("loop: Avoid updating block size under +exclusive owner") for the 6.6 kernel, because if the LTP ioctl_loop06 test is +run with this patch in place, the test will fail, it leaves the host unable to +kexec into the kernel again (hangs forever) and "losetup -a" will hang on +attempting to access the /dev/loopN device that the test has set up. + +The patch doesn't need to be reverted from 6.12, as it works fine there. + +Cc: stable@vger.kernel.org # 6.6.x +Signed-off-by: Eric Hagberg +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/block/loop.c | 38 ++++++++------------------------------ + 1 file changed, 8 insertions(+), 30 deletions(-) + +--- a/drivers/block/loop.c ++++ b/drivers/block/loop.c +@@ -1472,36 +1472,19 @@ static int loop_set_dio(struct loop_devi + return error; + } + +-static int loop_set_block_size(struct loop_device *lo, blk_mode_t mode, +- struct block_device *bdev, unsigned long arg) ++static int loop_set_block_size(struct loop_device *lo, unsigned long arg) + { + int err = 0; + +- /* +- * 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; +- } ++ if (lo->lo_state != Lo_bound) ++ return -ENXIO; + + err = blk_validate_block_size(arg); + if (err) + return err; + + if (lo->lo_queue->limits.logical_block_size == arg) +- goto unlock; ++ return 0; + + sync_blockdev(lo->lo_device); + invalidate_bdev(lo->lo_device); +@@ -1513,11 +1496,6 @@ static int loop_set_block_size(struct lo + 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; + } + +@@ -1536,6 +1514,9 @@ static int lo_simple_ioctl(struct loop_d + case LOOP_SET_DIRECT_IO: + err = loop_set_dio(lo, arg); + break; ++ case LOOP_SET_BLOCK_SIZE: ++ err = loop_set_block_size(lo, arg); ++ break; + default: + err = -EINVAL; + } +@@ -1590,12 +1571,9 @@ static int lo_ioctl(struct block_device + break; + case LOOP_GET_STATUS64: + return loop_get_status64(lo, argp); +- case LOOP_SET_BLOCK_SIZE: +- if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN)) +- return -EPERM; +- return loop_set_block_size(lo, mode, bdev, arg); + case LOOP_SET_CAPACITY: + case LOOP_SET_DIRECT_IO: ++ case LOOP_SET_BLOCK_SIZE: + if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN)) + return -EPERM; + fallthrough; diff --git a/queue-6.6/series b/queue-6.6/series index b0c77386c2..4b19a4c638 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -67,3 +67,4 @@ mptcp-propagate-shutdown-to-subflows-when-possible.patch minmax-avoid-overly-complicated-constant-expressions-in-vm-code.patch minmax-simplify-and-clarify-min_t-max_t-implementation.patch minmax-add-a-few-more-min_t-max_t-users.patch +revert-loop-avoid-updating-block-size-under-exclusive-owner.patch -- 2.47.3