From patchwork Wed Dec 11 20:42:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181323 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1042874ile; Wed, 11 Dec 2019 12:46:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwWph+Hw7JA1asqIDfrJBrtdMD4y8lKDkO7sq3ErtRXhIPLrQMArubuRKvVQGD4dIScJsDI X-Received: by 2002:a9d:4f0e:: with SMTP id d14mr3701012otl.90.1576097188255; Wed, 11 Dec 2019 12:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576097188; cv=none; d=google.com; s=arc-20160816; b=ViGtirhgIyVBP1Xdpmds1ix/F4gOGFsg+V0neHRJSvXQxM0a/BU8svxKY3VV5kFDho HbwtMyxVyWnuOOA/YKYz4ot9IA/tEUrqxH1Mkwq+G09H75QbHtKhec9FcUr5iSBfCfqs 8/ThUB+cgG9Wlh3GELaJi5CCVimKTIA9Yy6ZKx2TPH/TEgoftCAxbMpa36fkBprlAODy mXY447b41fLMkRKWCMJeIRwag6VkOntDTeYlcp4cSPsO4idvww7kztpoxV9BLG1q3Snb 4rNl8xIFhM+NHViGqqvHsjE0Sh4sd0NbuSe2bat/LMhuu0ALTn6RwDKYtnGAdWFW+ued kKpQ== 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=EhQiKEOdcOyWJSbRpfICSnw+M5DuuWTSmdfSQCog8WS8GBMBvfpiJu7YZ6ZDhZrSeH m8obrBy2/X3IDTbwepWgzQDTKecHmThJ3EKF7Io361+LWaxhaSRcmObrJ3Tt9dyNJbg8 E5DoBMv2IsLdxfx8dDukoAA+HcaakZ9Joxto+9+JThWcH4sc5dgkPWsXHHIJMP1+e0KT Y2BJviqW22xTSGlRJUZ5fHGasHdUDmWzqBGJlr4nOxXynDg8R6uu2o2gxbQGx8kcedUu MqSNI0fPErKQm+d9p9Jy7x2F0esLn7keeFMn4QYxvNej7RiHYvXLVG56bFjnNSuZNHHM psdQ== 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.27; Wed, 11 Dec 2019 12:46:28 -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 S1727053AbfLKUq0 (ORCPT + 27 others); Wed, 11 Dec 2019 15:46:26 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:34855 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726771AbfLKUq0 (ORCPT ); Wed, 11 Dec 2019 15:46:26 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MacWq-1i8qJS0cf4-00cBEd; Wed, 11 Dec 2019 21:45:32 +0100 From: Arnd Bergmann To: Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro Cc: linux-kernel@vger.kernel.org, y2038@lists.linaro.org, Arnd Bergmann , Jonathan Corbet , Mauro Carvalho Chehab , =?utf-8?q?Diego_Elio_Petten=C3=B2?= , Guenter Roeck , linux-block@vger.kernel.org Subject: [PATCH 09/24] compat_ioctl: move CDROMREADADIO to cdrom.c Date: Wed, 11 Dec 2019 21:42:43 +0100 Message-Id: <20191211204306.1207817-10-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:9eLcpqX9qM3wY9O4JMlBOGxtF6980Tea0e3xYW37bDIbuBQTU3d EBt9uH6NIbNAq3wnxnKjoZGRiY26U6pGdg8mn4FyQwBgKP3hprv2duU5iz3Bj/tpbriZqX1 rAicuFbxRQ2b8PzXcWI0CpjiIAIqjITj0IyontPLj5Ii8Z0oB8HwnOC5O59p9zHFz77n5DX vbJmPvFNQp9dPaV6e2OjA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:miUaOKDhzGc=:NQ5w4Tv6kJpsYc2hAv9MBL XPFl09NhiZJ8sFOqfF9F6Cr0nFZNVPknX8DvCdwadIpGG8vRZo0r2s0GEMW9I0GOEweeE4rtJ QULXit1ZqycFg4OdaK+bhQ9D/a6sGdIPqRq/savDBCKzANNZ8KcYlBXcH3WXNn+1eiAhEuDME QUqMGSkKqO+8dKz80yFyRPYmBlQNqi1yxHppfyltSyZHDwFSCH4vTKVPyYUCSE6+PK/wBR27z bDFmAi2h7AyJqvyBsvL0B15h67jZPpncHFqDMMsXIzYOtzFDinZ/Pk+Eiz+HAyjWEGmIY4WCk gjFVUOOF1DM3vptgfDBdc949e53LeRbkee6q1XSX9/knW68cf7dY4iqtT4YaMctWk0NVt6/Qq yOgqoJ+L2zfHVcjYpTo/mO7y+U9Jb9fGjPAEbC2dRKepMRAXlFp9orwg01MUw5gTHUFpNXF0r F4/0uYnJtIbL6UVVdPb4Mzz3N/yM3uwOBOCgZYXdTC5bfojvOjoooqbCZw0jbfo499FagB50m NTEyfrR+0mBnjv8tM4JMB2DDwb4rWu/gS6Om1UJVoBX7Q0rnHucA9D+5Ff57mZSCtB50gwMLl yb7btU8OddXIGAUuT6SWlQQAA9I4xsIJTnizjWoJpvJFJGioNGxOjXcsRpIGt20yHftYoNm5v HzHEwir5mPeDEw3UlbGCdrKs8aylgUiApZdYTe0ZwMOz0u6geXJq+fgdmkO4TUTMmsLoQauSF AruH41K6eLFBjyFIgqO6brjg92nbkNTjp2QNuLLonSDCIkuqB3RwIf0XXsw8fVFaD0GWoFDUA EjF4z4yAkWSlMWSADJPdLzeicqaNoSaOlGnSJeqz7KlHL6ICc7FfoKH7ZcHaZcWcmjysT1Glv kWY027vK4y78pBqNljdw== 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,