From patchwork Wed Dec 11 20:42:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181324 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1042940ile; Wed, 11 Dec 2019 12:46:31 -0800 (PST) X-Google-Smtp-Source: APXvYqylhzZ5rOKxN33o4fcmb+4Ao6viXhGPal3dqSphnHcAgJy+l1DTEfsu0NThc1pZ2wfcTOj3 X-Received: by 2002:a9d:6e89:: with SMTP id a9mr3718337otr.38.1576097191777; Wed, 11 Dec 2019 12:46:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576097191; cv=none; d=google.com; s=arc-20160816; b=KVdT2dQsH1y73xJkAybvGakYkSgNmJTjkMG8c26gI6iJaPzNnKJFpapoOj6XO4Ko9t hAdwkVrk9/6/fD0EzgtH+8sozl5TbK9Ok1kfGrf+VH7UMRs4xwE/zqs+bYhmykc0L9C0 07hdeE1wm7T5wsK8vuZUccjdLQ+OncUCJESlqPb7teUwwmhMrvFdnScpCLR5M9tSNTM7 wqv4kklkihCoGco+nCHEyOFGDTXAzpb+mglCGXIq/Sh7oV5gNyixbj7FhjkDk1I6STJR yA4d15ncBGX9LY8TXSWpYFS1zLHAghADEqVr7+YRVP/7NbMgFa0Zli8kSMJvXz13YtE6 09YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bHr7vznmK+jYeWprRgaBOffx2NPdRWjg6fbSJRf0a0s=; b=TZDb0yC0k0Xbk2duCHiCaGj2ZN4Ly6PUyOd0ktdHuZHc0c7eU5Scv+KMHf1srgk41k GBpYrxhC5ZuzuhS69FdEHYtJBapXBtCEPqsf8VbcB2aXqLH2LSSNbbpl8LamtXrWdNye 2/CIxM+gdmJ4du2E1cOsqlUbeY3ZZ+CyWJ/lHV6XTiHRQKoNYPNJF+IGFwjuLpy3P5ZK VkRjiGbjT53/hxUtHylNiTSrrVFvEZCWkC9kjUTGazJCOG/hLKO5ldU4oSCUqWf3n3MU 27iDOtT5E5pEhz1jY9RRgyTjf45saz9dyWc89hu0rMx2ebYuyiWvpd8gvlCkbVzNH5Gt xbfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si1687082otq.37.2019.12.11.12.46.31; Wed, 11 Dec 2019 12:46:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727077AbfLKUqa (ORCPT + 27 others); Wed, 11 Dec 2019 15:46:30 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:47121 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726771AbfLKUq3 (ORCPT ); Wed, 11 Dec 2019 15:46:29 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MdNPq-1i65A826tc-00ZQLd; Wed, 11 Dec 2019 21:45:44 +0100 From: Arnd Bergmann To: Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro , linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, y2038@lists.linaro.org, Arnd Bergmann , Martin Wilck , Hannes Reinecke , Jonathan Corbet , Mauro Carvalho Chehab , Guenter Roeck , =?utf-8?q?Diego_Elio_Petten=C3=B2?= Subject: [PATCH 10/24] compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN Date: Wed, 11 Dec 2019 21:42:44 +0100 Message-Id: <20191211204306.1207817-11-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191211204306.1207817-1-arnd@arndb.de> References: <20191211204306.1207817-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:OgKProSambYiHxIdc4WgI96dWkA775je0kzaKhUxPtesDlYoKyr gFFE1yy9DzEM7a5B5AA/oSqXoT7QuiY4bPuyHN27QCD94Ex8qoyXne6agA5MTSOyDSrPZGD b1iEfWDWCeor9YWE98KUBDkDqgzEcVe4XsydwGdKj0HN1+aNts0vphUCJe97+YwSV7Cwuc1 NPTBUBiYBp0q71uYDhjLg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Hu2x/EQ5Akw=:kkX8RCM7OH0NzXIm2tqs9i sLHHlNRUC31BYCN7hIZytGYHFX+czQfkQlwPZsH8e+XKW0dHB9up5hnk5z1rU4r2NUrUdAr0v VyFaamsfs6G8SqhUkpOmVGoWOAFaSQ9MrbqI8sLODVKtntYt8R9eWpeRcFnSTEuNb3g+whPI4 mSoYVxg6+8o8mtCTLdVnfxhCUDVnh8gqsJ4JQFVfHK22DWhxEvcMJ9T7tE6IdA9ZA/EZjXdGV sLfZpMxbGKRov84Jy/2ZqSVMIfpDQMWZXGjo/+qFZeKurqf54xnsjNmZsaPHpyaZBMnfiW+TX lCwVM07T3jmrVnam7Xonjfn9L7acTC6cFTWU9o7QQ+kpCJa/ZdAi70SzHbyMuOL4ZYkH05Xud mDpr4nwzEIgJLWzGkvxxX1iaWM1j4ZEEm9HjrCQlOCY8TCNRxHspFNWoOWvTOMzjjm8iD8Xua QvN6mPKXr5GZvwpMwnKbRHX+uEzUYLGg4npHHrWkdI/zRcVEjRL5Eza8kz+EtRENOfL6ITRXh zX8zKnuUaxBeEyYR/X5pQjKN0SeBGmVyB7RyJJSdUdUj8PsBoUMfCVEe2kyuBOSZPdzMyWBSh oXqLDy417zcfrnc+7Ec9vujspmUmVuaAc1qWxswpslZCkHlvfejhXZNJ4vt34IFAZSTkG28+y BmG53KpQIu9xron0cA3NL0rgACyTESFb8ouD/QfdlH5XSnKUcEzLZAd+9sLL35tAeKq1A9PSf kY7ij1PIMzoQc6ix9EpU5tLRR18Ky03ORsAG97f+/xE/WXSpPvyjACZw8W5Z1HkwulabSwBkC B5mgacsSWMkl7bJNu7JTb9YAezAK7f0wmDxlDBqeVfLIwvb4vJNJXpOMn3ZIPtML6Qg51rh4x UCB0u9rL3bexsg3A8PyA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) -- 2.20.0 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,