From patchwork Tue Dec 17 22:16:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181945 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6383249ile; Tue, 17 Dec 2019 14:19:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxKu88AqLPiW6GAQf1wCva2RaJ0USnBWn6i6S0OfL971P/orS617jy3fDewe+SUSW5514Lm X-Received: by 2002:a05:6808:a8e:: with SMTP id q14mr2854310oij.173.1576621154580; Tue, 17 Dec 2019 14:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621154; cv=none; d=google.com; s=arc-20160816; b=AWLvY0gEOunBiI7/hQ5j2fUx16ZQghx9TH2QVf1g4CSpRlA8Hx9dDNXbjxwArGFp/7 HSQvEHoh/wTJntWJzHjKCyA8I1sd9w6sMg4XwEUUkCt2mY24WNJepiV2HjWMVImgEOH6 MiAGUhwASn36G4mnUdtttiJKoi54UI344+ZT9TjRGLif4V+aCiNbPEKtjAqKSrVNKJvK UsshL6N0UOPCSYGTtmx7m6YmN9aXJ0fhq2SDrlNdJv3uAnPoEnqbgXGuDLxZTEpC9i8N QH+q80TcQ8+NMbPkOR9p8v4WuiBh5EX4yWMa1zSWJpFTqkzLvgT8Dms1JZAv/z75YkB+ Ya+w== 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=+IyWi71jOz+f1/EpORDZXIhsKPvu7kRnxluBl5Bn2rc=; b=Xv5UulMjaOmqhPMn1DOhPz98Z16tpaJIr13T00TpR6KsEczUF92Q93i3/5i1yGFoh5 BuIIO30qS6vx1TFBdBHVg1/MzixoJvg07JsBvhI1e7ghzW3VZ6OFbV341/6kCyLaI0b9 bVMxVBSAk8m4D/VkLh5l0AZy+t3PK7zoiDQ8J5XLX4aw/Jm7B+BS4BMamVjK1hUgQIwa uww/dOtM2/Ojs8yajoBBV31CR3p+z4wSMHUgWPb/F+NsLqR0Wphfo6UeVbterbhNZ00N X6iqXCMKOuyJyXAHxBEKIyD8RJB5KCj3dJ1XmhX+NIjNtFs8D3l9BmI04FLRibUvYXkb pLMw== 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 l14si452758oii.37.2019.12.17.14.19.14; Tue, 17 Dec 2019 14:19:14 -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 S1726777AbfLQWTM (ORCPT + 27 others); Tue, 17 Dec 2019 17:19:12 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:53763 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbfLQWRm (ORCPT ); Tue, 17 Dec 2019 17:17:42 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1N8GEY-1hdQgS2Y64-014F6s; Tue, 17 Dec 2019 23:17:28 +0100 From: Arnd Bergmann To: Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Ben Hutchings , linux-doc@vger.kernel.org, corbet@lwn.net, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v2 12/27] compat_ioctl: move CDROMREADADIO to cdrom.c Date: Tue, 17 Dec 2019 23:16:53 +0100 Message-Id: <20191217221708.3730997-13-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191217221708.3730997-1-arnd@arndb.de> References: <20191217221708.3730997-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:SEzk2cE2KU/nNwoHfidkX8tSUvACbWH8uSk5lxoIuhKQ5CztWxi bOWwXOzfL6LJLGSTM7iwROz0sna6duXBrCFvKGwnOsrAzq9Tg9pU9s7afIMaCaRpVGbyCN/ XwRKj4yFepn9WVTWTnBK2V3XIX2hZwlo+sFykVTcsN1BtuwMYi2wx4Oohc65URen5wcBFuc kGOwA5NDRqz4uDUVqyHtQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:HlEXxuefKnQ=:q2hK5YnnOvqsUKbyH+4ygI M+1LtTx6gRiGNH5cwDteqBKUew+WRP30dnsjs1CqXSY5tcG2Ji+XYJQ9fg74Lh/YtmFcIiDxi Wd5mr4n7Dob36GOioVZ0rnSOECG1wbZhlMDMr20rDGsI+87xKTZtYTgNG4DHoebf0r++6ZJFx D3cGh07tox4ZvxJp5blgH4rwItQP0lDSge2TLKnrbsF7/Azz4nQHzpzqIvAcOI45ni78YD7Q/ TGeD61+btd80HC99gaucfPqQHmud6suE08GOy/2X/2EzpfSHV2b+FFZHpAVW9n4BYDZY6E/o2 DlvTXTFpcVae8SsQm5vKEwO7KrhOm8iUBoD8hEIHOPuXLmNAMnRjC0z+M6eRZ23vwGbXFthBy SXLwKf4vDWdI1j2I5Hm+RmAuKnEnLqh/CxpZOJL8urWW6jmQD0BCso1Pr42qY6hntHQmClUZe 2uQM56dK/NVQe8Z9OwvO46PA+5OC/sRA2bQu548EgWAO/pLfXGWxOHcED0Wc2he6FlQYVIF1r DM+osZMXSMnLONmXnpSzJYHexkHQwDcD6Ilm4aSR0Bafc4LAqh3U904vhglbnuSXTBy4v28bG k+/bwy8R/clnpebnl0zPoUbXXhF71AMTm5PvJZZ9s1ugzjQwrwmk5VQ9AoKJGWUQSE18oxo0q cEe2qQy9AaufAKJ6c2Fr21LA3uqpwQ2CX1KJDBjvuVzkAhNRXV1iQFElVh1yeR03B+eFTPByi CpcpUkCYw7zZ7MEQQenSPWy/XRHmamdibRDpOvPyV9ZHYarpKVQ/JO/WHS2i2LowlZfjOhW92 9DvUema4JwLbhqhT3zOrL+qYxejCVGAPJhd1tDrKBuLXdyxrDxVziqd7Knxe6ltNa1Gjc+jDU a3jFykHFY1cSFNebaT1Q== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Again, there is only one file that needs this, so move the conversion handler into the native implementation. Signed-off-by: Arnd Bergmann --- block/compat_ioctl.c | 36 ------------------------------------ drivers/cdrom/cdrom.c | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 39 deletions(-) -- 2.20.0 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 578e04f94619..cf136bc2c9fc 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c @@ -95,40 +95,6 @@ static int compat_hdio_ioctl(struct block_device *bdev, fmode_t mode, return error; } -struct compat_cdrom_read_audio { - union cdrom_addr addr; - u8 addr_format; - compat_int_t nframes; - compat_caddr_t buf; -}; - -static int compat_cdrom_read_audio(struct block_device *bdev, fmode_t mode, - unsigned int cmd, unsigned long arg) -{ - struct cdrom_read_audio __user *cdread_audio; - struct compat_cdrom_read_audio __user *cdread_audio32; - __u32 data; - void __user *datap; - - cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio)); - cdread_audio32 = compat_ptr(arg); - - if (copy_in_user(&cdread_audio->addr, - &cdread_audio32->addr, - (sizeof(*cdread_audio32) - - sizeof(compat_caddr_t)))) - return -EFAULT; - - if (get_user(data, &cdread_audio32->buf)) - return -EFAULT; - datap = compat_ptr(data); - if (put_user(datap, &cdread_audio->buf)) - return -EFAULT; - - return __blkdev_driver_ioctl(bdev, mode, cmd, - (unsigned long)cdread_audio); -} - struct compat_blkpg_ioctl_arg { compat_int_t op; compat_int_t flags; @@ -178,8 +144,6 @@ static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode, case HDIO_GET_ADDRESS: case HDIO_GET_BUSSTATE: return compat_hdio_ioctl(bdev, mode, cmd, arg); - case CDROMREADAUDIO: - return compat_cdrom_read_audio(bdev, mode, cmd, arg); /* * No handler required for the ones below, we just need to diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index eebdcbef0578..48095025e588 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -3017,9 +3017,31 @@ static noinline int mmc_ioctl_cdrom_read_audio(struct cdrom_device_info *cdi, struct cdrom_read_audio ra; int lba; - if (copy_from_user(&ra, (struct cdrom_read_audio __user *)arg, - sizeof(ra))) - return -EFAULT; +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) { + struct compat_cdrom_read_audio { + union cdrom_addr addr; + u8 addr_format; + compat_int_t nframes; + compat_caddr_t buf; + } ra32; + + if (copy_from_user(&ra32, arg, sizeof(ra32))) + return -EFAULT; + + ra = (struct cdrom_read_audio) { + .addr = ra32.addr, + .addr_format = ra32.addr_format, + .nframes = ra32.nframes, + .buf = compat_ptr(ra32.buf), + }; + } else +#endif + { + if (copy_from_user(&ra, (struct cdrom_read_audio __user *)arg, + sizeof(ra))) + return -EFAULT; + } if (ra.addr_format == CDROM_MSF) lba = msf_to_lba(ra.addr.msf.minute,