Message ID | 20191211204306.1207817-11-arnd@arndb.de |
---|---|
State | Accepted |
Commit | ab8bc5417d8cf62a5fc515737b391689573e7fb3 |
Headers | show |
Series | block, scsi: final compat_ioctl cleanup | expand |
On Wed, 2019-12-11 at 21:42 +0100, Arnd Bergmann wrote: > This is the only ioctl command that does not have a proper > compat handler. Making the normal implementation do the > right thing is actually very simply, so just do that by > using an in_compat_syscall() check to avoid the special > case in the pkcdvd driver. [...] Since this uses blkdev_compat_ptr_ioctl() it needs to be moved after the following patch. Ben. -- Ben Hutchings, Software Developer Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom
On Tue, Dec 17, 2019 at 4:20 PM Ben Hutchings <ben.hutchings@codethink.co.uk> wrote: > > On Wed, 2019-12-11 at 21:42 +0100, Arnd Bergmann wrote: > > This is the only ioctl command that does not have a proper > > compat handler. Making the normal implementation do the > > right thing is actually very simply, so just do that by > > using an in_compat_syscall() check to avoid the special > > case in the pkcdvd driver. > [...] > > Since this uses blkdev_compat_ptr_ioctl() it needs to be moved after > the following patch. > Ah right, I obviously reshuffled my patches too much to end up with the most reasonable order and avoid introducing something that would be removed again later. I'll split out the addition of blkdev_compat_ptr_ioctl() into a separate patch and move that all in front, as I'm no longer sure if there was another dependency in the other way. Thanks! Arnd
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index ab4d3be4b646..5f970a7d32c0 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2663,26 +2663,6 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, return ret; } -#ifdef CONFIG_COMPAT -static int pkt_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) -{ - switch (cmd) { - /* compatible */ - case CDROMEJECT: - case CDROMMULTISESSION: - case CDROMREADTOCENTRY: - case CDROM_SEND_PACKET: /* compat mode handled in scsi_cmd_ioctl */ - case SCSI_IOCTL_SEND_COMMAND: - return pkt_ioctl(bdev, mode, cmd, (unsigned long)compat_ptr(arg)); - - /* FIXME: no handler so far */ - default: - case CDROM_LAST_WRITTEN: - return -ENOIOCTLCMD; - } -} -#endif - static unsigned int pkt_check_events(struct gendisk *disk, unsigned int clearing) { @@ -2704,9 +2684,7 @@ static const struct block_device_operations pktcdvd_ops = { .open = pkt_open, .release = pkt_close, .ioctl = pkt_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = pkt_compat_ioctl, -#endif + .compat_ioctl = blkdev_compat_ptr_ioctl, .check_events = pkt_check_events, }; diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 48095025e588..faca0f346fff 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -3293,9 +3293,10 @@ static noinline int mmc_ioctl_cdrom_last_written(struct cdrom_device_info *cdi, ret = cdrom_get_last_written(cdi, &last); if (ret) return ret; - if (copy_to_user((long __user *)arg, &last, sizeof(last))) - return -EFAULT; - return 0; + if (in_compat_syscall()) + return put_user(last, (__s32 __user *)arg); + + return put_user(last, (long __user *)arg); } static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
This is the only ioctl command that does not have a proper compat handler. Making the normal implementation do the right thing is actually very simply, so just do that by using an in_compat_syscall() check to avoid the special case in the pkcdvd driver. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/block/pktcdvd.c | 24 +----------------------- drivers/cdrom/cdrom.c | 7 ++++--- 2 files changed, 5 insertions(+), 26 deletions(-) -- 2.20.0