mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-02 07:00:42 -04:00
loop: revert exclusive opener loop status change
This commit effectively reverts the following two commits:2704024d83("loop: add missing bd_abort_claiming in loop_set_status")08e136ebd1("loop: don't change loop device under exclusive opener in loop_set_status") as there are reports of them causing issues with unmounting. As we're close to the 6.19 kernel release and the original author hasn't taken a closer look at this yet, revert them for release. Reported-by: nokangaroo <nokangaroo@aon.at> Link: https://lore.kernel.org/all/62de4453-17e8-47f6-a10b-39bf5a49fdee@leemhuis.info/ Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -1225,28 +1225,16 @@ static int loop_clr_fd(struct loop_device *lo)
|
||||
}
|
||||
|
||||
static int
|
||||
loop_set_status(struct loop_device *lo, blk_mode_t mode,
|
||||
struct block_device *bdev, const struct loop_info64 *info)
|
||||
loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
|
||||
{
|
||||
int err;
|
||||
bool partscan = false;
|
||||
bool size_changed = false;
|
||||
unsigned int memflags;
|
||||
|
||||
/*
|
||||
* 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_status, NULL);
|
||||
if (err)
|
||||
goto out_reread_partitions;
|
||||
}
|
||||
|
||||
err = mutex_lock_killable(&lo->lo_mutex);
|
||||
if (err)
|
||||
goto out_abort_claiming;
|
||||
|
||||
return err;
|
||||
if (lo->lo_state != Lo_bound) {
|
||||
err = -ENXIO;
|
||||
goto out_unlock;
|
||||
@@ -1285,10 +1273,6 @@ loop_set_status(struct loop_device *lo, blk_mode_t mode,
|
||||
}
|
||||
out_unlock:
|
||||
mutex_unlock(&lo->lo_mutex);
|
||||
out_abort_claiming:
|
||||
if (!(mode & BLK_OPEN_EXCL))
|
||||
bd_abort_claiming(bdev, loop_set_status);
|
||||
out_reread_partitions:
|
||||
if (partscan)
|
||||
loop_reread_partitions(lo);
|
||||
|
||||
@@ -1368,9 +1352,7 @@ loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info)
|
||||
}
|
||||
|
||||
static int
|
||||
loop_set_status_old(struct loop_device *lo, blk_mode_t mode,
|
||||
struct block_device *bdev,
|
||||
const struct loop_info __user *arg)
|
||||
loop_set_status_old(struct loop_device *lo, const struct loop_info __user *arg)
|
||||
{
|
||||
struct loop_info info;
|
||||
struct loop_info64 info64;
|
||||
@@ -1378,19 +1360,17 @@ loop_set_status_old(struct loop_device *lo, blk_mode_t mode,
|
||||
if (copy_from_user(&info, arg, sizeof (struct loop_info)))
|
||||
return -EFAULT;
|
||||
loop_info64_from_old(&info, &info64);
|
||||
return loop_set_status(lo, mode, bdev, &info64);
|
||||
return loop_set_status(lo, &info64);
|
||||
}
|
||||
|
||||
static int
|
||||
loop_set_status64(struct loop_device *lo, blk_mode_t mode,
|
||||
struct block_device *bdev,
|
||||
const struct loop_info64 __user *arg)
|
||||
loop_set_status64(struct loop_device *lo, const struct loop_info64 __user *arg)
|
||||
{
|
||||
struct loop_info64 info64;
|
||||
|
||||
if (copy_from_user(&info64, arg, sizeof (struct loop_info64)))
|
||||
return -EFAULT;
|
||||
return loop_set_status(lo, mode, bdev, &info64);
|
||||
return loop_set_status(lo, &info64);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1569,14 +1549,14 @@ static int lo_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||
case LOOP_SET_STATUS:
|
||||
err = -EPERM;
|
||||
if ((mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN))
|
||||
err = loop_set_status_old(lo, mode, bdev, argp);
|
||||
err = loop_set_status_old(lo, argp);
|
||||
break;
|
||||
case LOOP_GET_STATUS:
|
||||
return loop_get_status_old(lo, argp);
|
||||
case LOOP_SET_STATUS64:
|
||||
err = -EPERM;
|
||||
if ((mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN))
|
||||
err = loop_set_status64(lo, mode, bdev, argp);
|
||||
err = loop_set_status64(lo, argp);
|
||||
break;
|
||||
case LOOP_GET_STATUS64:
|
||||
return loop_get_status64(lo, argp);
|
||||
@@ -1670,9 +1650,8 @@ loop_info64_to_compat(const struct loop_info64 *info64,
|
||||
}
|
||||
|
||||
static int
|
||||
loop_set_status_compat(struct loop_device *lo, blk_mode_t mode,
|
||||
struct block_device *bdev,
|
||||
const struct compat_loop_info __user *arg)
|
||||
loop_set_status_compat(struct loop_device *lo,
|
||||
const struct compat_loop_info __user *arg)
|
||||
{
|
||||
struct loop_info64 info64;
|
||||
int ret;
|
||||
@@ -1680,7 +1659,7 @@ loop_set_status_compat(struct loop_device *lo, blk_mode_t mode,
|
||||
ret = loop_info64_from_compat(arg, &info64);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return loop_set_status(lo, mode, bdev, &info64);
|
||||
return loop_set_status(lo, &info64);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1706,7 +1685,7 @@ static int lo_compat_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||
|
||||
switch(cmd) {
|
||||
case LOOP_SET_STATUS:
|
||||
err = loop_set_status_compat(lo, mode, bdev,
|
||||
err = loop_set_status_compat(lo,
|
||||
(const struct compat_loop_info __user *)arg);
|
||||
break;
|
||||
case LOOP_GET_STATUS:
|
||||
|
||||
Reference in New Issue
Block a user