From patchwork Thu Jan 2 14:55:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11315897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0A91139A for ; Thu, 2 Jan 2020 14:59:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A95D420848 for ; Thu, 2 Jan 2020 14:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728695AbgABO7p (ORCPT ); Thu, 2 Jan 2020 09:59:45 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:60677 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728544AbgABO7p (ORCPT ); Thu, 2 Jan 2020 09:59:45 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1N49xZ-1jn8pu1q4X-0105tC; Thu, 02 Jan 2020 15:59:07 +0100 From: Arnd Bergmann To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , linux-block@vger.kernel.org, Jens Axboe , Hannes Reinecke , Martin Wilck , Jonathan Corbet , Mauro Carvalho Chehab , Guenter Roeck , =?utf-8?q?Diego_Elio_Petten=C3=B2?= , linux-kernel@vger.kernel.org Subject: [PATCH v3 08/22] compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN Date: Thu, 2 Jan 2020 15:55:26 +0100 Message-Id: <20200102145552.1853992-9-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20200102145552.1853992-1-arnd@arndb.de> References: <20200102145552.1853992-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:IWmxlyxI1qDwO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NRqDlNjDOSHir/6LmTkAobhf1E4VP8TJpS5q+6KqHFHo7+rFa9NO2DpUam4YdD0VVbN 96L9Bcrit/jRuaAjbsTQ== Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org 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 --- drivers/block/pktcdvd.c | 24 +----------------------- drivers/cdrom/cdrom.c | 7 ++++--- 2 files changed, 5 insertions(+), 26 deletions(-) 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,