Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN

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.

Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+5 -26
+1 -23
drivers/block/pktcdvd.c
··· 2663 2663 return ret; 2664 2664 } 2665 2665 2666 - #ifdef CONFIG_COMPAT 2667 - static int pkt_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) 2668 - { 2669 - switch (cmd) { 2670 - /* compatible */ 2671 - case CDROMEJECT: 2672 - case CDROMMULTISESSION: 2673 - case CDROMREADTOCENTRY: 2674 - case CDROM_SEND_PACKET: /* compat mode handled in scsi_cmd_ioctl */ 2675 - case SCSI_IOCTL_SEND_COMMAND: 2676 - return pkt_ioctl(bdev, mode, cmd, (unsigned long)compat_ptr(arg)); 2677 - 2678 - /* FIXME: no handler so far */ 2679 - default: 2680 - case CDROM_LAST_WRITTEN: 2681 - return -ENOIOCTLCMD; 2682 - } 2683 - } 2684 - #endif 2685 - 2686 2666 static unsigned int pkt_check_events(struct gendisk *disk, 2687 2667 unsigned int clearing) 2688 2668 { ··· 2684 2704 .open = pkt_open, 2685 2705 .release = pkt_close, 2686 2706 .ioctl = pkt_ioctl, 2687 - #ifdef CONFIG_COMPAT 2688 - .compat_ioctl = pkt_compat_ioctl, 2689 - #endif 2707 + .compat_ioctl = blkdev_compat_ptr_ioctl, 2690 2708 .check_events = pkt_check_events, 2691 2709 }; 2692 2710
+4 -3
drivers/cdrom/cdrom.c
··· 3293 3293 ret = cdrom_get_last_written(cdi, &last); 3294 3294 if (ret) 3295 3295 return ret; 3296 - if (copy_to_user((long __user *)arg, &last, sizeof(last))) 3297 - return -EFAULT; 3298 - return 0; 3296 + if (in_compat_syscall()) 3297 + return put_user(last, (__s32 __user *)arg); 3298 + 3299 + return put_user(last, (long __user *)arg); 3299 3300 } 3300 3301 3301 3302 static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,