Re: [PATCH 4/4] loop: Add LOOP_SET_FD_AND_STATUS ioctl.
From: Christoph Hellwig
Date: Wed Apr 22 2020 - 04:07:58 EST
On Wed, Apr 22, 2020 at 10:06:17AM +0200, Martijn Coenen wrote:
> > line at the top of lo_compat_ioctl, and switches the LOOP_SET_STATUS
> > and LOOP_GET_STATUS case to it?
>
> Did you mean in regular lo_ioctl()?
Yes, sorry.
> eg something like this:
>
> @@ -1671,6 +1671,7 @@ static int lo_ioctl(struct block_device *bdev,
> fmode_t mode,
> unsigned int cmd, unsigned long arg)
> {
> struct loop_device *lo = bdev->bd_disk->private_data;
> + void __user *argp = (void __user *) arg;
> int err;
>
> switch (cmd) {
> @@ -1694,21 +1695,19 @@ static int lo_ioctl(struct block_device *bdev,
> fmode_t mode,
> case LOOP_SET_STATUS:
> err = -EPERM;
> if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) {
> - err = loop_set_status_old(lo,
> - (struct loop_info __user *)arg);
> + err = loop_set_status_old(lo, argp);
> }
> break;
> case LOOP_GET_STATUS:
> - return loop_get_status_old(lo, (struct loop_info __user *) arg);
> + return loop_get_status_old(lo, argp);
> case LOOP_SET_STATUS64:
> err = -EPERM;
> if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) {
> - err = loop_set_status64(lo,
> - (struct loop_info64 __user *) arg);
> + err = loop_set_status64(lo, argp);
> }
> break;
> case LOOP_GET_STATUS64:
> - return loop_get_status64(lo, (struct loop_info64 __user *) arg);
> + return loop_get_status64(lo, argp);
Exactly!