From patchwork Tue Dec 17 22:16:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181955 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6387100ile; Tue, 17 Dec 2019 14:22:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxjnIoyx/lUwkt9nOgSkoRS64AqXhudP2eH8WHP9EHwvbPTH6WXyMJTWNgGoDflidpgX69+ X-Received: by 2002:a9d:367:: with SMTP id 94mr641893otv.329.1576621362698; Tue, 17 Dec 2019 14:22:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621362; cv=none; d=google.com; s=arc-20160816; b=tA3qisit4SpKU6c2I1CW6eW90/HNruAFxWZ8LKoCXodHG4DDPLD2n+2/XBK7lTXdzy 94Ri6U86kr76n7KB7WQFm0g/vREb6aZU6g5OslQ98OA9mfiKBF0gIazOqomPAeQ/Ao8y RWvd2CmGmV1QKp6mhjLfBgOy2MDdyEKd1gUdQq27Bd8OWrX+PI8fs4lbIlSRBnqTPDKc uNTaz81ajYAb/V5D+Gf+OJdLMAWDPju2XCuIxCG9wPrhX5Mgn/8MJdF+pLc3UQL4Cn4O BtcMOY8k4MBcPrd1GCPswKH8SxKuQlfSFK3ZXKEMOagjsofnU0MyoUcRvXENIri9zoT5 bQ9g== 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=TCIwKOUeabTZsIms0Eij8m5W0Evd/GMIh5XZPqDOjlY=; b=zXZVkznw5QstaxhcPVJAa4W4Mv+/5pNzNBiL6zwAa3nKODxLBMTz/igdTAjVwNxfMz WUVWJKhPJ75YGG44q4yrs0Jb/Uh4DLfs4G+QCIn3ZGQk1RRca4H8jT1uW1Gv33pSzAJ4 ajq4alQ8q7BI3lbkRcyj8F8PvcRO2qpMJMLNtzVlQ1CqLdBRsUtVg/nc17RkAm1C2LUG LyY49y97P0k2gOM/jCcx5vK5xUxutkXTI2V3NJRh3Z0CfYo6gW2455qRxb1dA8wlvN0T y/cM4egI4DSV3ZcAbQnlBepd7SekkgI+uxqdiq8FUeuZyslZVbobenS4k1DdLl7ffddd 0wDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 t7si14139977otl.133.2019.12.17.14.22.42 for ; Tue, 17 Dec 2019 14:22:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726721AbfLQWWl (ORCPT ); Tue, 17 Dec 2019 17:22:41 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:43763 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725975AbfLQWWk (ORCPT ); Tue, 17 Dec 2019 17:22:40 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1N4yyQ-1hiwzo35zY-010xJi; Tue, 17 Dec 2019 23:17:24 +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 , Damien Le Moal Subject: [PATCH v2 04/27] compat_ioctl: block: handle add zone open, close and finish ioctl Date: Tue, 17 Dec 2019 23:16:45 +0100 Message-Id: <20191217221708.3730997-5-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:gu/sZ8TIEZHaNMokJWZJ2X/rL2ysrVtrFNyi0SMX6prix2pGIWW bAPVJ8fwpN8E/mH6Nc/QBm6u/qo4Tvn5SQjEffGJQQ0pqczFhRJkII1FGsCprkk0Bm9Mp7S bPZtEphmmlcYdUTV6MyI0eM1M+OkiwJopBU1dcguNoVzj0J/NcGJldmWoOE4st0Vk3Wc+EZ AsAGp/sInmVO2GHX+D+bg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:PZzd4xrTh1k=:O4HFuv5nV8diiq/ph5n5Gr qf4n+7oCpROKsWo1y2SYeW91P85f6Qflgw/6lY7L1mr97wtEbH6FSNZD5YVHljnyqEpuEge/x igMySXnwDbTKop7DCYDSAsYWFVUMr82xvXBwq9CPkuIyH3mWCbap4y+gTZtGuR5UVlO9XD0DX csBbpzz/fdeVdn18z9BVw7IF0cP3xbNq9ATsOs4oO2D23gSuRlETFGY32yYd+mld9NAAfFFID VntMuQCrGbwBsICwhCOcBfGmUQFGHlG8hOaNOHQPQNgbo2l5f0h0uSF0wQCr3UQG1a7jLq0zP E8hunDXra3WNSNh+Fb48UCaYoj1hqmAylf69bDnJJNO1AMGd4ydVAj1sGBqKEjliixmMVBQ6D aybJCJCv/RJiJMT8Lvh3jgCFKX9VURq5G/vMOvSArwRi7Bp1/IQCuAkhvIXPQKed4dFIMy7qj GGZ0FmDM1X/sOr2EDL572pMUoPN8lDpApPfjkar0u31u3tzsmWWpPIIw3DAb9bMOOCIH101zL /z6ilD/gTLCeVqMjNQXZH34TDDsMp8sjlHLXGBmC0jdp8OyQsWNpOL4nOZFdbxPq/nbXE+97f NeW73c8z807bRs9C15zVqFwVrTZHPWYl9fq20EOQG8FStNxQx7028GQpWMPvqxFiZPcpOyUxf a4r8+swDX3SaUnxU5fiwKyqNrx5bfGZ/kl4iNtSz8xpXT68QSSY1JZ4chjAiHdtk0/k+lk1iP +s8EGZZJVn+Hqf8F/NdDYJZM0dpzajmFia1hLchlr6J7nLCK+yEzAdNmhVGQwLPV1hC1U1szV 4PY/3xiTfZkiaDLxyvlIrB5l+LE7JEd/x7p0JTG5Ze7QPa1vX/AeCbYOtkhpJYT5ZwM0lqEUY C1MhosgOmGZqGHhJZDIw== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org These were added to blkdev_ioctl() in linux-5.5 but not blkdev_compat_ioctl, so add them now. Fixes: e876df1fe0ad ("block: add zone open, close and finish ioctl support") Reviewed-by: Damien Le Moal Signed-off-by: Arnd Bergmann --- block/compat_ioctl.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.20.0 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index f5c1140b8624..5b13e344229c 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c @@ -356,6 +356,9 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) case BLKRRPART: case BLKREPORTZONE: case BLKRESETZONE: + case BLKOPENZONE: + case BLKCLOSEZONE: + case BLKFINISHZONE: case BLKGETZONESZ: case BLKGETNRZONES: return blkdev_ioctl(bdev, mode, cmd, From patchwork Tue Dec 17 22:16:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181933 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6381526ile; Tue, 17 Dec 2019 14:17:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxAYzHs7kJ7nv0+nMi7UfSYydEFUVuU5hG067vAmLJgG4iiIoHelZvgL54WG37NqAYQ+znj X-Received: by 2002:a9d:6e15:: with SMTP id e21mr40102792otr.125.1576621068377; Tue, 17 Dec 2019 14:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621068; cv=none; d=google.com; s=arc-20160816; b=ntJJ1cmcM0q6YIyYXgzZNs1/JHfPu242dkmQnh2yAJvQc1Og5sCmkihjocvEygc3GN H5BgO6+b8epntltKs00J351SXSeY8o9XLLb46/RbcJFq7r9BYVuJftoQm7WlIMhzqBk3 LTT8yHDU+33gkzQXX19YSxY1vgeIlkpgRtae76/yHOIC2x0Uqt8kk6RPB4hmrgggDU69 /4E7rILM2GaqvrUvXTVgmF8emknq4aUS4J89x4GgRoo9fFs4YkPYWD4Xnk0HLtJ+TcwR 04k+XlFIgjmMFthfTzYVGfEH+Aa4VbBE9dtkRxdyWMxL9IHs1yCNcQRq79GkF6XYEecs 75SA== 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=j/SjjQr1ILLD3eO+ROejTWCCNPl1zDlUIDNWOJetMYg=; b=L5SPTJn7nF9fNq7L4rwRIqthTrmuxd8kg0Sn9a1x7HCcE5KlRuHlVYY80QZfJHD2oC i4SX7e48k5bXj7NSj2rlmagfojOyFZemvpauzCVuna9ClufkbG8xRJRg6tY5YwmEweDs ij39fQhNGOxguZq+PcQTL3zDCDpldLfJxfWBhGXe6bdKMjDdTLJ+iBV9O8yi5Rz4PkA4 QSSrrwz87l64lZjHMyC/AQVQszGF2qaHpi1FOrdJtE5xr63hF3CmhkT/vTTQdLDs6eZl kxsmcvERSfc7cP/4y2r6/W6tAIF7TmO3Kktg8ybfJGn0dNt7rPPYPvCHWQ7nw713SoeT MaxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 t1si12443707oth.94.2019.12.17.14.17.48 for ; Tue, 17 Dec 2019 14:17:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726721AbfLQWRq (ORCPT ); Tue, 17 Dec 2019 17:17:46 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:59431 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbfLQWRp (ORCPT ); Tue, 17 Dec 2019 17:17:45 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MYeZB-1iClIj1FHX-00VjN7; Tue, 17 Dec 2019 23:17:26 +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 07/27] compat: provide compat_ptr() on all architectures Date: Tue, 17 Dec 2019 23:16:48 +0100 Message-Id: <20191217221708.3730997-8-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:JQSrPBZB1v54Yak8eCxwsTN2osR5c2EDNvd2k/ZMRPAcktmSN0p 0fdwV7ZLRKeFe22G22lsYhOVb7fG8iMrKpNMhA31Ai70EsIcBqiwRSIRz0TaOov3uJNwpM8 E7OhyP/EXJFunAt6QnSJpCwKkqFNH7+wrY2aODNXbKUqkd+b5BPWLaLHXbThNqv5JMiq4NG Im68FZLXOCLcTEu9dIi/w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:SU+7KpO9Vlo=:IymVgWc94KXwaMyZQlHkxU BOOd8tlE2cnTW2MvLxOion+33s57k6FjyPd7rKinV0H3dz+KmdD/evvVKhnUMABxn+b00xCuu o/npD4lIIJI4P/kYPC43N0VqKYay/3o1lR6k8gVP4B8BsCGE34HJUOeqMDPvGw2aXU+HaPgVY EZ9F+sG1CluLGd5DLGKDpqEQ9kseqCkQHkxHP4ZoqbTuM+25Im3fouqTeqYgQeNs690gOTXHH x0fnsDxJcFxMpsmhSVWfDw4ONU77MlG692O1y4OjYs2Tvp5a68CsW9vftGnhm94l4dEL/l5bT EWeKpphlgJgYsHcM3bHOXp9MSEc8GyeREGfPcFiGVvXuVAaO7tLlqxTirbh/c/JoLcf7l9yER l7mqFc9qjeWIk5nHLsHKQEBGYTdliY6ouRe5YNNel4VuiNqz9mBhvb42Q5n+PdnPyXgK8w+/h 8S8bzNO9XoOQSGFzDaz9DvBmFMft5VI/Cc0QkPIZOxB8iSDr+NYsfEzkOR2Y97RlTBNpyw0vU iMP3UoVKuxRkIB+2D7XTPvcDh1WJGvjg3yT3UZNaSW86f4seyz0vd0sGVDLNEInJgRadp8VeG YGx4A8+q4/WdWRn9lL06Kami1FMJda5mm350WsvKTFT8Xm3yHDpVh9mKA7k3lF0ZQfaAh76qs PS5g5Rd7T75Z8i5NmvHEKkS8q7PMBzsvMicAg4x7rxxsH7/KDB5sn/7kOuMV1Wpc/6wMgg0xE vm5TLPMfcGfm8wnQ76w09fCVRt6AFS9lsNRTynMX8kM6yTvIOJmiE4h8qXpAFCbKAJCLs/wXg q/KyMKqUtjSx/JJ4+dp90OW3lcafIOkTUavcY+uXgYS9XKscy11asz0jREQHu5j2AowzaVJav 4WLifMKTsbfDkjC9gOMQ== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In order to avoid needless #ifdef CONFIG_COMPAT checks, move the compat_ptr() definition to linux/compat.h where it can be seen by any file regardless of the architecture. Only s390 needs a special definition, this can use the self-#define trick we have elsewhere. Signed-off-by: Arnd Bergmann --- arch/arm64/include/asm/compat.h | 17 ----------------- arch/mips/include/asm/compat.h | 18 ------------------ arch/parisc/include/asm/compat.h | 17 ----------------- arch/powerpc/include/asm/compat.h | 17 ----------------- arch/powerpc/oprofile/backtrace.c | 2 +- arch/s390/include/asm/compat.h | 6 +----- arch/sparc/include/asm/compat.h | 17 ----------------- arch/x86/include/asm/compat.h | 17 ----------------- include/linux/compat.h | 18 ++++++++++++++++++ 9 files changed, 20 insertions(+), 109 deletions(-) -- 2.20.0 diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index 7b4172ce497c..935d2aa231bf 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -114,23 +114,6 @@ typedef u32 compat_sigset_word; #define COMPAT_OFF_T_MAX 0x7fffffff -/* - * A pointer passed in from user mode. This should not - * be used for syscall parameters, just declare them - * as pointers because the syscall entry code will have - * appropriately converted them already. - */ - -static inline void __user *compat_ptr(compat_uptr_t uptr) -{ - return (void __user *)(unsigned long)uptr; -} - -static inline compat_uptr_t ptr_to_compat(void __user *uptr) -{ - return (u32)(unsigned long)uptr; -} - #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current))) #define COMPAT_MINSIGSTKSZ 2048 diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h index c99166eadbde..255afcdd79c9 100644 --- a/arch/mips/include/asm/compat.h +++ b/arch/mips/include/asm/compat.h @@ -100,24 +100,6 @@ typedef u32 compat_sigset_word; #define COMPAT_OFF_T_MAX 0x7fffffff -/* - * A pointer passed in from user mode. This should not - * be used for syscall parameters, just declare them - * as pointers because the syscall entry code will have - * appropriately converted them already. - */ - -static inline void __user *compat_ptr(compat_uptr_t uptr) -{ - /* cast to a __user pointer via "unsigned long" makes sparse happy */ - return (void __user *)(unsigned long)(long)uptr; -} - -static inline compat_uptr_t ptr_to_compat(void __user *uptr) -{ - return (u32)(unsigned long)uptr; -} - static inline void __user *arch_compat_alloc_user_space(long len) { struct pt_regs *regs = (struct pt_regs *) diff --git a/arch/parisc/include/asm/compat.h b/arch/parisc/include/asm/compat.h index e03e3c849f40..2f4f66a3bac0 100644 --- a/arch/parisc/include/asm/compat.h +++ b/arch/parisc/include/asm/compat.h @@ -173,23 +173,6 @@ struct compat_shmid64_ds { #define COMPAT_ELF_NGREG 80 typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; -/* - * A pointer passed in from user mode. This should not - * be used for syscall parameters, just declare them - * as pointers because the syscall entry code will have - * appropriately converted them already. - */ - -static inline void __user *compat_ptr(compat_uptr_t uptr) -{ - return (void __user *)(unsigned long)uptr; -} - -static inline compat_uptr_t ptr_to_compat(void __user *uptr) -{ - return (u32)(unsigned long)uptr; -} - static __inline__ void __user *arch_compat_alloc_user_space(long len) { struct pt_regs *regs = ¤t->thread.regs; diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h index 74d0db511099..3e3cdfaa76c6 100644 --- a/arch/powerpc/include/asm/compat.h +++ b/arch/powerpc/include/asm/compat.h @@ -96,23 +96,6 @@ typedef u32 compat_sigset_word; #define COMPAT_OFF_T_MAX 0x7fffffff -/* - * A pointer passed in from user mode. This should not - * be used for syscall parameters, just declare them - * as pointers because the syscall entry code will have - * appropriately converted them already. - */ - -static inline void __user *compat_ptr(compat_uptr_t uptr) -{ - return (void __user *)(unsigned long)uptr; -} - -static inline compat_uptr_t ptr_to_compat(void __user *uptr) -{ - return (u32)(unsigned long)uptr; -} - static inline void __user *arch_compat_alloc_user_space(long len) { struct pt_regs *regs = current->thread.regs; diff --git a/arch/powerpc/oprofile/backtrace.c b/arch/powerpc/oprofile/backtrace.c index 43245f4a9bcb..6ffcb80cf844 100644 --- a/arch/powerpc/oprofile/backtrace.c +++ b/arch/powerpc/oprofile/backtrace.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #define STACK_SP(STACK) *(STACK) diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h index 63b46e30b2c3..9547cd5d6cdc 100644 --- a/arch/s390/include/asm/compat.h +++ b/arch/s390/include/asm/compat.h @@ -177,11 +177,7 @@ static inline void __user *compat_ptr(compat_uptr_t uptr) { return (void __user *)(unsigned long)(uptr & 0x7fffffffUL); } - -static inline compat_uptr_t ptr_to_compat(void __user *uptr) -{ - return (u32)(unsigned long)uptr; -} +#define compat_ptr(uptr) compat_ptr(uptr) #ifdef CONFIG_COMPAT diff --git a/arch/sparc/include/asm/compat.h b/arch/sparc/include/asm/compat.h index 30b1763580b1..40a267b3bd52 100644 --- a/arch/sparc/include/asm/compat.h +++ b/arch/sparc/include/asm/compat.h @@ -125,23 +125,6 @@ typedef u32 compat_sigset_word; #define COMPAT_OFF_T_MAX 0x7fffffff -/* - * A pointer passed in from user mode. This should not - * be used for syscall parameters, just declare them - * as pointers because the syscall entry code will have - * appropriately converted them already. - */ - -static inline void __user *compat_ptr(compat_uptr_t uptr) -{ - return (void __user *)(unsigned long)uptr; -} - -static inline compat_uptr_t ptr_to_compat(void __user *uptr) -{ - return (u32)(unsigned long)uptr; -} - #ifdef CONFIG_COMPAT static inline void __user *arch_compat_alloc_user_space(long len) { diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index 22c4dfe65992..52e9f3480f69 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h @@ -177,23 +177,6 @@ typedef struct user_regs_struct compat_elf_gregset_t; (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)) #endif -/* - * A pointer passed in from user mode. This should not - * be used for syscall parameters, just declare them - * as pointers because the syscall entry code will have - * appropriately converted them already. - */ - -static inline void __user *compat_ptr(compat_uptr_t uptr) -{ - return (void __user *)(unsigned long)uptr; -} - -static inline compat_uptr_t ptr_to_compat(void __user *uptr) -{ - return (u32)(unsigned long)uptr; -} - static inline void __user *arch_compat_alloc_user_space(long len) { compat_uptr_t sp; diff --git a/include/linux/compat.h b/include/linux/compat.h index 68f79d855c3d..11083d84eb23 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -958,4 +958,22 @@ static inline bool in_compat_syscall(void) { return false; } #endif /* CONFIG_COMPAT */ +/* + * A pointer passed in from user mode. This should not + * be used for syscall parameters, just declare them + * as pointers because the syscall entry code will have + * appropriately converted them already. + */ +#ifndef compat_ptr +static inline void __user *compat_ptr(compat_uptr_t uptr) +{ + return (void __user *)(unsigned long)uptr; +} +#endif + +static inline compat_uptr_t ptr_to_compat(void __user *uptr) +{ + return (u32)(unsigned long)uptr; +} + #endif /* _LINUX_COMPAT_H */ From patchwork Tue Dec 17 22:16:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181952 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6384435ile; Tue, 17 Dec 2019 14:20:10 -0800 (PST) X-Google-Smtp-Source: APXvYqxx0LkTxbzi+ur1WAdfEV8kffD87QmgbYvgpAupk6CPqX7ScTcGQwoVNWP9vkruWNFTqJs9 X-Received: by 2002:a9d:4e97:: with SMTP id v23mr38226754otk.201.1576621210533; Tue, 17 Dec 2019 14:20:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621210; cv=none; d=google.com; s=arc-20160816; b=EAQtJRfbbGDsX+YgF7MzfORRXOKcxfm+V3nGXigKcLg3Wzo+VPa1QCUrDsYocOpcbR Xj+rpxBXYCLwLd34RdHP9jXUxICd3HYJ8/PcWa29+TBmGdr2KW9c7dKEEBen7swjyyZE Ljz5/TJn3Pv0QZFQPWl49sRDKODxo9tTinEcrHL00T6ggEkPscrD2GQ/br5bWPCUfser uV/AotdLSKAs218F+iQpK2E1iIUQ0krKMbrZt7wQLI3XTzVc5IkCJSUdmwtN9k8NbpAI 1NSXrdl3fOwlROH4/F1toARVOMMGRESABRHpsQYPbMz79ld2eEJADorquYh/wpEBCPsC CQnA== 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=Ui+PwTKn8A+c8+qMLznZVwQaSecG+968WggH9whL7Sg=; b=BqtsoqQO4311SYP5zdFWuOkRq4K97GrEuDy/D23jCfwL/xaZ1p5E6ObJFFizmx8nYw PEGntnU5xieYHFDHNts5K8lNXngoo2ezRq3nGhSGm/rKl5r1sA59Cs2+SHhBhe6CDC9B m3rYXL9DmA5DpAJ/Die3FuZijrJLZoPUZ2saS9QSiq+U2A4i0ozfk060H5L0sap20JyW Q5oX3c9NeD4oxRJdV0U8jXJm5Cy+X6EYbOQ0ggj5hTWtSYxad1pUl61XA+/R0HeD43Lk Xxw2feXxbBbDHhBmntIYa4HZ2mj7WoVedesLZQJSAfkFail3wervIQ8oJhBiZK/GoPsT 4Nbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 i20si12149178otk.270.2019.12.17.14.20.10 for ; Tue, 17 Dec 2019 14:20:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727367AbfLQWUJ (ORCPT ); Tue, 17 Dec 2019 17:20:09 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:60465 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726569AbfLQWRi (ORCPT ); Tue, 17 Dec 2019 17:17:38 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MLz7f-1iPOdC2idl-00Hxzz; Tue, 17 Dec 2019 23:17:27 +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 10/27] compat_ioctl: ubd, aoe: use blkdev_compat_ptr_ioctl Date: Tue, 17 Dec 2019 23:16:51 +0100 Message-Id: <20191217221708.3730997-11-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:pXgtQR2qBCnSxJSJP7Y8qCzLQ/VoWcKI8ZIUVUSLjozoL96eoEm jS/dQT773HwnIlYtCaz/VwTxsgiorHcK0GE59g6ES4DCAbJYDR1pNRuCqoUrPHL4Ry4d3U7 TBlboU8N5E4h71VTNV7UqnqgBwVPx8dGUD6nhs40UU5t+Hdgl82MsiuumI+NIWKdfJpzvX4 BT+G3Xk7tKgva9zDuTjig== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:3Sn1qxFJj1c=:tUMSxbPiYFrI6EX1e3mwt7 rHN1+PnajD2XFYaIDBNraD9FEMOuqalFH++3MPe70YKbWzHjPVXp2SL1e2amVBuwM/tQF2poX ZAxg9IGxSpByjPBLphmGwJ8tzfMgc23wRM9E/pheclEc7m26cxOfl3TGgSCxXueTFmEB3ohUE 8SFPImb/0CCIBMaoCC2lrjkTXrQWtrhzYfy0hXOg5SKiZCFOn2hsV1NwgrfqVUF2XXM4zDZB3 mFdH5RfFHOMubdOiTJhBtV81Q6rN0AaRiJ2t9RYKpPKv8kBfzJsECcI2K3Wo6P3e84R8oAQ/+ 8TSMWS/N3oAkC0IXVoOtDUhRyPVSZnXGkarWjwRIAkOZ+m1p0E1QXhImXsX71oNmMzdJNOk17 LbnQyUIr+3uUxLO/OKVOqRlfMs0UBbLGTD/7WdEw8jF3Lxy1jW8ohmVl35A9BqT57HpCnJz6H ttP+634RpDmKwCHYo+tJT3VYhKH5pOi7ScDUJPa5Vcaqc6WOgT56/xSvxPWv5SQp/2+TsCOOe YMqIbm2UwTskJlSOMI72+cmdPr+mFZomb7+1H5hjHOuj6HNO9PLZ7KLPCjgs+bJoYdqWKCXFO oAvSVUClMcvqPYvrqNSGkawmqmMsocU5kEZQGQV8/+FbJMXd+iN3AyE4T2iZQrk76Lbci7NCc U4jzy012goNB6UshKCU1nzNVTz2E1LKl7rD8liiurZhA7iCl4VsKQEMOSuS557ulSbEkt+thf sHP2x/MvCyoZiGz5M2N2lUQhAX1hz1I3NDvqZ7pT1wef7kU8blXu2l61NyozCxE59CEaM6fNv MakRtMJYuEDJbktoFgqDV2ycF6ZejToGYzbs6Qj86pA/GACn7UrBO5Uup/i/sqiz9Axo6UzW+ 6CAa68o34dGq7Dc9F0mA== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org These drivers implement the HDIO_GET_IDENTITY and CDROMVOLREAD ioctl commands, which are compatible between 32-bit and 64-bit user space and traditionally handled by compat_blkdev_driver_ioctl(). As a prerequisite to removing that function, make both drivers use blkdev_compat_ptr_ioctl() as their .compat_ioctl callback. Signed-off-by: Arnd Bergmann --- arch/um/drivers/ubd_kern.c | 1 + drivers/block/aoe/aoeblk.c | 1 + 2 files changed, 2 insertions(+) -- 2.20.0 diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 6627d7c30f37..582eb5b1f09b 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -113,6 +113,7 @@ static const struct block_device_operations ubd_blops = { .open = ubd_open, .release = ubd_release, .ioctl = ubd_ioctl, + .compat_ioctl = blkdev_compat_ptr_ioctl, .getgeo = ubd_getgeo, }; diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index bd19f8af950b..7b32fb673375 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -329,6 +329,7 @@ static const struct block_device_operations aoe_bdops = { .open = aoeblk_open, .release = aoeblk_release, .ioctl = aoeblk_ioctl, + .compat_ioctl = blkdev_compat_ptr_ioctl, .getgeo = aoeblk_getgeo, .owner = THIS_MODULE, }; From patchwork Tue Dec 17 22:16:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181944 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6382996ile; Tue, 17 Dec 2019 14:19:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyI2KHoHbAvcYAXN4DJ728loqFDL03iclPEhTUyN9QUYyCoYD4o19Lx5hwMmffiJoq8QVlI X-Received: by 2002:aca:c507:: with SMTP id v7mr3098788oif.157.1576621143358; Tue, 17 Dec 2019 14:19:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621143; cv=none; d=google.com; s=arc-20160816; b=YxzZNO/mJ8ZEoJjftEcK9PzosNrW7elDGkbS70P2vAT7ax88ZE2ic9r128cAA+BHkK 3IWtzXL97vG/fdRyUwAFw2CQCShG7BoBeB92Cc830phaqxQEtmXL4gH0V47yYarXLpm5 okhXkdqVpuyqw0/gDL9f5U8UrhaRmjGsQYDgXbKXczZwqNezFDdrdxKSl+8Wmpj0NxKk lskoRRgJRqTWJrdrMruEn0fq0uTXF2xJZ2Rmt3bxVo1URCs5md46JaIcoL1Qc2WLHArQ 0ctwAdGjg27gVQ+CVX1QrnWiD29F+cVLE9Mo/L4nxA92iZnSxswrLdJtyGDOrekCJbbP z7DQ== 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=oz9Eju0tK0jrHAg6UgX1vD/YTKi8B0qAg+4jS65/gCz9w3+iDh+zsiasI0osC2hdHF AiPY+NsVtLy1Bz1RrQmcCx7peIrf6XAsl64X8tkQKp4vpQh/cMYu18rblBASsqrmqvyN TEu+A/+R8218lZ0UyEAqu9iY6yTSckgi9HltebuncJuZHaGaVp+ys8LxbiQslihWWKo4 KaqPXRagzxEdEX4/4saQpG9/X13B1oBNG/e6gYWhjyyDi8FAMo8Srmx8q26U5B2rwidh peno8e70heIA8Tof+UInQVMQhItzpjfXW2WzVmZaqsL1xpy5qLbauOLeu5ZIz/hAqGdL dLug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 a64si1759002oii.266.2019.12.17.14.19.03 for ; Tue, 17 Dec 2019 14:19:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbfLQWTC (ORCPT ); Tue, 17 Dec 2019 17:19:02 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:42327 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfLQWRn (ORCPT ); Tue, 17 Dec 2019 17:17:43 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MPGNn-1iJtNk0HCn-00PeZf; Tue, 17 Dec 2019 23:17:29 +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 13/27] compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN Date: Tue, 17 Dec 2019 23:16:54 +0100 Message-Id: <20191217221708.3730997-14-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:wpOzJeFufAHUVew0tCAOYce8zMXOPidyJEDHZ6pQ5GaUKg8+CDX h7MBzbcLPVMio9kfQoSfOTfY3vxyKEJ51kkTL2W9m6KoiixxPeES/rPHhLYMS3HLccXegsv k2H3sqymCqH2WEdNBVYO+Pa/7nVD5p4xIpTPyQbpKaEF5BnOtpu5V76Hk5QKEhX0c57O6+9 iqqUYAqmFhuT18BCsoAUg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:CIB+4OQSR64=:WBhyckcX/5l7eAeTjvEoM/ w4upkT4JvAY0/CRT9+NICNrKfxWQgzFpdAAXj+N/219xyoUp3i3ArASxNj5M5wRYKgkvQZQxH CxE3wmmlICtVcCt38Iyj0fCz219veSow7XvDStghM7YdHK3Dyc6tvlWWXjGrbbVRnSjwPfDRg eVtYANDyKpGQXAf9W7W90lMaNv5QMnxNMgyq39t/ISQtLXqABgziP8W2h45E7twP5VBot7roC GL1ML1O03UlrCwfpOAkcgAdPWAHJZqUm3sBBK5njNHfVE35o5IBtcTuXdtKRnOvtk0yQoGDSJ VvyZRKQAB0hgxPqN29PkxvMSJi7nxkkeU4eEQ5e5E0s4OkSUgjPjtxtDSBpGBgdgb26I7jH2L WThg17UcmwvgV1keBdbZ4b/FITTwdodVlLprRQoVJYBHU+DHryNHvKqiVjmu2hjYvq+APMZRQ 8CqFFoQLK9j+/z4XOJvkjTBW3oFG5EyvDNVM6yeAWb/gJ/Q/cK4dMzs8/h2w38PPOyVOH+8CJ GIOD1toGYO9NJ1N9oFYeeglO/lAFX7OvezRPohzgPi2aoCJB6ApyXKb4gonN+8Fv4HMFm0YAn arCC0GtPppbxPq3gxhB8lsLrZSS2AFE+ix/mk7W8HSVu6ItzoancGQHxY/wKZjbbETFZm5fPJ /14Hk/KHBiHbbD+jpVUF0Y+Gf1ti/u7yMF0lQGlVccJE3OH+qD4WefTxzFl5aPUrsX15aFR1w Cc0R5lYy8WI3de9J8he5JIBk4eYo4gSYrrHC7sS4ng7SAXuIfuf+vpYVaZYyqumJzv7yGEiiG i+9Lx5d/5ai3pOwDpQnQJJ3YqYcqWsPmuRATJOiCUiObGVXUhY5YSaDw3y0R2ptIuC1ixKtTh QEy6XnI1qqp/ZZw4o4iQ== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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, From patchwork Tue Dec 17 22:16:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181939 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6382074ile; Tue, 17 Dec 2019 14:18:16 -0800 (PST) X-Google-Smtp-Source: APXvYqw1SytVbkBkz0NE7880Nk1oWWM+uCrEoPs60Aw6HZOz4sV+YSSMP6ZjpNkIzqz05CgCKN7L X-Received: by 2002:a54:4482:: with SMTP id v2mr2851722oiv.0.1576621096668; Tue, 17 Dec 2019 14:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621096; cv=none; d=google.com; s=arc-20160816; b=phGkluqUGqgo1ZiLRUSqK9NQgImGYtaZZQORuTkIm1Q7YOElSR3ZSaO+hlAbzhFNHu /iytQpo9FCI1Ka42xTXJdle1HQND0gktgz6C/0mY/aJEBRiKbc+EcPBhtf+4NBhQkBX+ YWzNh1qcaAl2IZCfIHqCnMmPSLvTirMCusSsKi6iAYga5GF5/9CWRrg9HSH0EQfiM0ZV SUaXvXeThzfPJ/IVYCFBm3LpGYJPcP2/hX35qTz+zh/0iNmxFoRQ3n/IdQbucCaytL+7 L/TpQfkivpdLQdignkM7HqhRMbAH2WzQH6Sf+0P5PaCwrwqG0SW9VpfSb3ogxYocEeM6 iNSg== 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=bSMoH68OJuS2SiyqIA0a/D4rZaEt5209rKVTqBaz+Zw=; b=Br7yFr3bNW/l1/LhBuiogbJuoCqqUS90amHFof0AyXLUlMeXS0z782K3Dubi57xOmO 6frL5Fr+Vf953wV5AY/mSPDFZrkH3w/OpLVldBgNNADPgNzHHCPjzmifvwF0o/TBQavc G3sMoAaKX6kHB4RzBNvYNk6tRTxfD03CckKKC+On77XlwxIm4cxqrhQ5SCvAwBu3nPuH W+hPgH1fHFjQU01UoguM8k8/hV/LZ8G9gryR0UIrVLbHpbpydLLCISFAl59dWF18DSma iHpc+iatEtI3OOSfBQInUOMvJTYWM4embCRFrBLTb9cGMucLV0Pu1yUwW+m7PD+RQDR5 /5Ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 v15si15192134otn.100.2019.12.17.14.18.16 for ; Tue, 17 Dec 2019 14:18:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726930AbfLQWSP (ORCPT ); Tue, 17 Dec 2019 17:18:15 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:36663 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726865AbfLQWSB (ORCPT ); Tue, 17 Dec 2019 17:18:01 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1Mn2iP-1i0tG23yJr-00k6zJ; Tue, 17 Dec 2019 23:17:30 +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 15/27] compat_ioctl: add scsi_compat_ioctl Date: Tue, 17 Dec 2019 23:16:56 +0100 Message-Id: <20191217221708.3730997-16-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:7+9fPO46Y0HOH2OsOUifwZayoQFbXANj+Oa9VP+1U7rh8ZhZZ8F 3hxCkpaA0NO2kdv6ZjC7Pgek4BhVndAGAH74m7t3INTUHKuOrVeEt1zDk8MHcDHm51AGTFB i36qQDfnTVO+CYDUu1JMmlixsSxong5R851SGfuaWLQN8Xk51RMnN8aiZwuYw/GZ0rdzqWU ivSwaSOO+EgFMWYzMvC3g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:yXc2hnIb6Ew=:BmbRqeeBaGxFN50taxmFBo AY7Ftkhhc9Z2VsPCHIDRN/ZHcQLs60RU/ZEvxvBwZIglimP546GHVde0vtrNsMN2HtblCPxPw rBRQKO2ARkBnklEkN+iMV8MEZhJ8srTpBNGo8nfXETXa7SNAXtW+768+tj9dtTYADhOLIf958 8gTa2Y/MsH++UEcuF1GQfQGgKH0pqtWukenVKl/gFUeDh2sgrNtRNQW9jwS6C+dnOAfguHCH1 ID4Qs/pfPtvcNkWQWOYnC8Cxk0EhwbG3kPjv18zQNtWROCysQsIKEMg+mrkJhhD9kz6QHTcQJ 4Qsm7lKUNqfcqQKd8/ifFRcooygBwXfk0H+pw5ae8EzcVq1VETJSXA34T9Ryrmz53GrgMYoL6 EIFHi7mI4La9/ty+0u/a8wHeKGVttDL80Ve3WItZ2vjoButtXX39HOuDaUWPZnD+owBuSfdhG Qfv/6nqIAQr5JvRqQuDM7oJ55+Eyja+eWaVUfp6XTUoRRVOfW4sY0HhnelNN6575s1Ri+zwmS rgNyU+vhYg3HUOqdkydSJ16lwkzL+ZM8b/ZYMqlil81ogT9V0OHOaMJMboTsf8bUhDIn3UNyd GdrCgPPUYp0N6SRsm9h5v/5lrCmgyINDBzuHm6Aq/2WRJOe179VmvhYwVJ7WoyjKaFx+oQ+Hz +/QDIQBT9HWa4Cc+67t5UsCVSoIAAEb3h0sFHmNakFM/D8ySgTVTW6EUuNTABasAetCKik53V G1D/SAS96Qlaky35Ws5whccdgGnA0xfZYAWRT6trmwdon9U0fcmT9ICdsZ3oRrzZ/tymL4h7Y QG0c9EQ4J1FnZrfxc09XCL1xwnf8QaZGZFuI14EaA3IG+nEKpmEWbKf9yh/ZzGlgoVthHYykV WGe2+u3w+mZZxg6ytwlw== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In order to move the compat handling for SCSI ioctl commands out of fs/compat_ioctl.c into the individual drivers, we need a helper function first to match the native ioctl handler called by sd, sr, st, etc. Signed-off-by: Arnd Bergmann --- drivers/scsi/scsi_ioctl.c | 54 +++++++++++++++++++++++++++++---------- include/scsi/scsi_ioctl.h | 1 + 2 files changed, 41 insertions(+), 14 deletions(-) -- 2.20.0 diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 57bcd05605bf..8f3af87b6bb0 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -189,17 +189,7 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg) } -/** - * scsi_ioctl - Dispatch ioctl to scsi device - * @sdev: scsi device receiving ioctl - * @cmd: which ioctl is it - * @arg: data associated with ioctl - * - * Description: The scsi_ioctl() function differs from most ioctls in that it - * does not take a major/minor number as the dev field. Rather, it takes - * a pointer to a &struct scsi_device. - */ -int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) +static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg) { char scsi_cmd[MAX_COMMAND_SIZE]; struct scsi_sense_hdr sense_hdr; @@ -266,14 +256,50 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) return scsi_ioctl_get_pci(sdev, arg); case SG_SCSI_RESET: return scsi_ioctl_reset(sdev, arg); - default: - if (sdev->host->hostt->ioctl) - return sdev->host->hostt->ioctl(sdev, cmd, arg); } + return -ENOIOCTLCMD; +} + +/** + * scsi_ioctl - Dispatch ioctl to scsi device + * @sdev: scsi device receiving ioctl + * @cmd: which ioctl is it + * @arg: data associated with ioctl + * + * Description: The scsi_ioctl() function differs from most ioctls in that it + * does not take a major/minor number as the dev field. Rather, it takes + * a pointer to a &struct scsi_device. + */ +int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) +{ + int ret = scsi_ioctl_common(sdev, cmd, arg); + + if (ret != -ENOIOCTLCMD) + return ret; + + if (sdev->host->hostt->ioctl) + return sdev->host->hostt->ioctl(sdev, cmd, arg); + return -EINVAL; } EXPORT_SYMBOL(scsi_ioctl); +#ifdef CONFIG_COMPAT +int scsi_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) +{ + int ret = scsi_ioctl_common(sdev, cmd, arg); + + if (ret != -ENOIOCTLCMD) + return ret; + + if (sdev->host->hostt->compat_ioctl) + return sdev->host->hostt->compat_ioctl(sdev, cmd, arg); + + return ret; +} +EXPORT_SYMBOL(scsi_compat_ioctl); +#endif + /* * We can process a reset even when a device isn't fully operable. */ diff --git a/include/scsi/scsi_ioctl.h b/include/scsi/scsi_ioctl.h index 5101e987c0ef..4fe69d863b5d 100644 --- a/include/scsi/scsi_ioctl.h +++ b/include/scsi/scsi_ioctl.h @@ -44,6 +44,7 @@ typedef struct scsi_fctargaddress { int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, int cmd, bool ndelay); extern int scsi_ioctl(struct scsi_device *, int, void __user *); +extern int scsi_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg); #endif /* __KERNEL__ */ #endif /* _SCSI_IOCTL_H */ From patchwork Tue Dec 17 22:17:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181935 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6381763ile; Tue, 17 Dec 2019 14:18:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxaCmwkg51gPAc/LU44CS1sgWC/4I/9iEfREiAERlgDfzJTlHLMhmb204PDvSUIfqdkz32f X-Received: by 2002:aca:5d57:: with SMTP id r84mr3070331oib.42.1576621080468; Tue, 17 Dec 2019 14:18:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621080; cv=none; d=google.com; s=arc-20160816; b=M9UiBgpl1kBwQUQUqqVPp3Jjgrn+bE9vI2FGG44sVtSNvZGLliGOPuUai58ycYMgTW dFYPkiB4P+R0jJVpcOO8fbYJYdfc1nIM1Kd1OSn6Kuw8Qb6SZ+dmbB1s1RGVyt7kwiJe mRlUNBtduxERk+vzInGww8sdWPXDg3BGsjFU3Mem1Z8WzYtK670g7Xr/YdzlRIEjmAwp P7e6g8YdtD1hXx6knogONT+B0x9mKTbzI+p3WHCYk2BLm/geijimnvJOkOAQXNd7O/Xu xnCE1ZScp1sluVe2PopcWO0KS009G55sPCxugHOqvdVmEIgGMPEc3TGnFFtXl/1y/fS/ 1VZQ== 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=I2iubamz4SQwC/dne1lcARk5QXyzvIf7Z+kXRy3axZM=; b=hOs0OVeTCQzg9cmU0B8mKahBJyHxIhrR5Bg0oX57k1S7jMtPuo93h8NjTv1/UlkMao hYHw6WykoN2dAUV2CKVw9TuUcELEcsrUAqeX/ONPmBXoapfIZaiSmg4WPhUALanHx2vi C1taA6JM4V614v4/NrG2vh2j4RaVy60GepEalCFGciIxwu5v61U2mzIxjSJWPYS7oBl+ Dih3pazQzJh+xLo32HcB0xejHd6ikYsCjBv/MbO2xCG04pU301xjscummDgQwI47JBDa YBnwZiDSWxpjoDTXZjZb/KvjV8U9BKex9UChyTnmhZ0C3Z1Uy0I4uWHC0yyuOpUCErk0 i/6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 s139si12996613oih.17.2019.12.17.14.18.00 for ; Tue, 17 Dec 2019 14:18:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbfLQWR7 (ORCPT ); Tue, 17 Dec 2019 17:17:59 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:49789 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbfLQWR4 (ORCPT ); Tue, 17 Dec 2019 17:17:56 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1M9WmQ-1ie1lZ0nQ4-005V7i; Tue, 17 Dec 2019 23:17:33 +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 22/27] compat_ioctl: scsi: handle HDIO commands from drivers Date: Tue, 17 Dec 2019 23:17:03 +0100 Message-Id: <20191217221708.3730997-23-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:pSOIrqA4qJmN8oxuhXgjjmKQ4BKDNp8za+fcHrSHtYc7EmHxMCJ ttBmqAyhcKzs6ALP6XaKjK1eJRepY36qUdiG1Ymlv2tcIEYRshLq2jDytMfphz3+jMw7eED id44i00bAoVEZGiADfmkRWGK5ysYfQDl/ODvN/WylYpI/Cktg36r4HXzmChOoQKwPNw7hC/ O3MQzKNY2II5A2Xp9GQdg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Xn6+UU1gPkE=:Bv08/Fta262/hxm73yaJG7 y492BZ90Db600sYHwNqoIUQnWSm/atwksEsV1xp4NNp+CuzOfClXWkCfHdzavBqpGJCXYsADl vsmudpY7oDIEyFAjmwugJe7iYi4PjkrHdo5qZkpsN8w1DKViflSW2rPR2e5voJyJ9rox3y7iN plV4XfZj1mR3aln6NxFOC1UypUU90Ai+Cb6ebfnlEtP2XU6jXiXSJURAAK2v1MIUWklgOS+93 zfO79A0IX1aK6C0kywszdTyW8pWLpkHrMHazzve/V23DJfGKpYm/he8UEA0WHkmJYk8GuYHt4 kQxgpRdDZ7qUhlolIqv4eHS0sJ6gCxZb+xys2yDg3btFd+ZCKP2KXfpl1CPzp7MDxtQg0UQjo lKszOsvC3Q3ebmbqqaGdKnNmL+twKhlgxfXxc/kfcwIJ3xdo2j81H5rL0+fySEJrkup0JhbBc V9sX9uZEwtJxBF0KiPsIEmU7b2TJya1sdrM3dhSEriIPs0ATUHlFQerrOAYD8MoEbfcoMlcgz CeS7mhMKIjLCtQiyeOl4ZHCycZ5y4wVJJD/IXMu+J8tPrVU3F+6UeGGxgjukY6zzcK/CwUy9s AuB708Q3h1gujO3R0e0382zazvQo+ZbVSzds+5y6Mp5DgXoXRnjaSHH2w0sT6RP5iZMYOwlNe VS9VHsWdnczFV8kUE5ATZeyFAVeYgyjqQ5ptFuFU00D7Y1Tt7pyJE2f+3FEX26n40HkD/eivx xV4aJqVGW+KCy4QWKcu49XXy8bUUPvMiBKyWbdVFQCO3a9iGlYg9bSJaA7BeGjPCfdHTW7fgl CpIl21r4ov345QUtxFOnW8wJaGmk2O1kY3SohSN4rBQibpmDdrMyaZUAn81EfAk6wWFFR3TrJ SXCRbLBNlUDixrQa7A5Q== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The ata_sas_scsi_ioctl() function implements a number of HDIO_* commands for SCSI devices, it is used by all libata drivers as well as a few drivers that support SAS attached SATA drives. The only command that is not safe for compat ioctls here is HDIO_GET_32BIT. Change the implementation to check for in_compat_syscall() in order to do both cases correctly, and change all callers to use it as both native and compat callback pointers, including the indirect callers through sas_ioctl and ata_scsi_ioctl. Signed-off-by: Arnd Bergmann --- drivers/ata/libata-scsi.c | 9 +++++++++ drivers/scsi/aic94xx/aic94xx_init.c | 3 +++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 +++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 +++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 +++ drivers/scsi/ipr.c | 3 +++ drivers/scsi/isci/init.c | 3 +++ drivers/scsi/mvsas/mv_init.c | 3 +++ drivers/scsi/pm8001/pm8001_init.c | 3 +++ include/linux/libata.h | 6 ++++++ 10 files changed, 39 insertions(+) -- 2.20.0 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 58e09ffe8b9c..eb2eb599e602 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -17,6 +17,7 @@ * - http://www.t13.org/ */ +#include #include #include #include @@ -761,6 +762,10 @@ static int ata_ioc32(struct ata_port *ap) return 0; } +/* + * This handles both native and compat commands, so anything added + * here must have a compatible argument, or check in_compat_syscall() + */ int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev, unsigned int cmd, void __user *arg) { @@ -773,6 +778,10 @@ int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev, spin_lock_irqsave(ap->lock, flags); val = ata_ioc32(ap); spin_unlock_irqrestore(ap->lock, flags); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + return put_user(val, (compat_ulong_t __user *)arg); +#endif return put_user(val, (unsigned long __user *)arg); case HDIO_SET_32BIT: diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index f5781e31f57c..d022407e5645 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -54,6 +54,9 @@ static struct scsi_host_template aic94xx_sht = { .eh_target_reset_handler = sas_eh_target_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = sas_ioctl, +#endif .track_queue_depth = 1, }; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 3af53cc42bd6..fa25766502a2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1772,6 +1772,9 @@ static struct scsi_host_template sht_v1_hw = { .eh_target_reset_handler = sas_eh_target_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = sas_ioctl, +#endif .shost_attrs = host_attrs_v1_hw, .host_reset = hisi_sas_host_reset, }; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 61b1e2693b08..545eaff5f3ee 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3551,6 +3551,9 @@ static struct scsi_host_template sht_v2_hw = { .eh_target_reset_handler = sas_eh_target_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = sas_ioctl, +#endif .shost_attrs = host_attrs_v2_hw, .host_reset = hisi_sas_host_reset, }; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index bf5d5f138437..fa05e612d85a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3075,6 +3075,9 @@ static struct scsi_host_template sht_v3_hw = { .eh_target_reset_handler = sas_eh_target_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = sas_ioctl, +#endif .shost_attrs = host_attrs_v3_hw, .tag_alloc_policy = BLK_TAG_ALLOC_RR, .host_reset = hisi_sas_host_reset, diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 079c04bc448a..ae45cbe98ae2 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -6727,6 +6727,9 @@ static struct scsi_host_template driver_template = { .name = "IPR", .info = ipr_ioa_info, .ioctl = ipr_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ipr_ioctl, +#endif .queuecommand = ipr_queuecommand, .eh_abort_handler = ipr_eh_abort, .eh_device_reset_handler = ipr_eh_dev_reset, diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 1727d0c71b12..b48aac8dfcb8 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -168,6 +168,9 @@ static struct scsi_host_template isci_sht = { .eh_target_reset_handler = sas_eh_target_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = sas_ioctl, +#endif .shost_attrs = isci_host_attrs, .track_queue_depth = 1, }; diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index da719b0694dc..7af9173c4925 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -47,6 +47,9 @@ static struct scsi_host_template mvs_sht = { .eh_target_reset_handler = sas_eh_target_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = sas_ioctl, +#endif .shost_attrs = mvst_host_attrs, .track_queue_depth = 1, }; diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index ff618ad80ebd..3c6076e4c6d2 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -101,6 +101,9 @@ static struct scsi_host_template pm8001_sht = { .eh_target_reset_handler = sas_eh_target_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = sas_ioctl, +#endif .shost_attrs = pm8001_host_attrs, .track_queue_depth = 1, }; diff --git a/include/linux/libata.h b/include/linux/libata.h index d3bbfddf616a..e68d05febe5a 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1109,6 +1109,11 @@ extern void ata_host_init(struct ata_host *, struct device *, struct ata_port_op extern int ata_scsi_detect(struct scsi_host_template *sht); extern int ata_scsi_ioctl(struct scsi_device *dev, unsigned int cmd, void __user *arg); +#ifdef CONFIG_COMPAT +#define ATA_SCSI_COMPAT_IOCTL .compat_ioctl = ata_scsi_ioctl, +#else +#define ATA_SCSI_COMPAT_IOCTL /* empty */ +#endif extern int ata_scsi_queuecmd(struct Scsi_Host *h, struct scsi_cmnd *cmd); extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev, unsigned int cmd, void __user *arg); @@ -1340,6 +1345,7 @@ extern struct device_attribute *ata_common_sdev_attrs[]; .module = THIS_MODULE, \ .name = drv_name, \ .ioctl = ata_scsi_ioctl, \ + ATA_SCSI_COMPAT_IOCTL \ .queuecommand = ata_scsi_queuecmd, \ .can_queue = ATA_DEF_QUEUE, \ .tag_alloc_policy = BLK_TAG_ALLOC_RR, \ From patchwork Tue Dec 17 22:17:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181938 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6381901ile; Tue, 17 Dec 2019 14:18:08 -0800 (PST) X-Google-Smtp-Source: APXvYqytrXWOtNRH9WjurdgKG4QoXaSSWwsqpyyB6In9JJvcdNXE3yF9+iUUCqoR+4CWQZJJBuYw X-Received: by 2002:a05:6830:1353:: with SMTP id r19mr41275004otq.288.1576621088515; Tue, 17 Dec 2019 14:18:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576621088; cv=none; d=google.com; s=arc-20160816; b=i0gd8DyYyBUlyvw2uM3Tvb/ZKmmdm/fIHaNsV+E2xaeD0ACPDl9SK35vYtoVvnjjNl Ic2fUNdKmGMEE4Tpzdtx1RfFtNZuMxoSTKl/wzkdbzTbWwyXyrsHb0s02hZEi18ya9fg gkBa5xKmSx6HPt+5/Q7V8lBejTcq/kktIj69SCtgrzuTclQc6RYDd7Rvk8SaXaCsPrqh vll86HK1Y4YT7iMB5fyM8hKNQhJSZ5wGRuRA/H8eeoTn4ZPkZUT78tELs0tAoLjOHfIB rLh4gUQIw6/ecWwmii5EfjG73TRGeMgUnApp9w3rpeaC5+98S0y9YzcyC2u0a+qDdJrJ 5t8A== 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=7esNQgvxFZZ29q2ZX9acOal/ZucVbMmghE85Lbd2/NY=; b=WYHVbcAQN7jEQ7W4QjCzfzSYckJHhy8ncx41nAu7ED4riMhYfrC48Wtyn/uhq8ZKoT Yi1lxq9EGbx6x5+IyktlcIkXCrqlM5nytx8rJMDhDeoCj9ZSFlUealB3fGjMWmHTO+CR qHbaKk0kfWjkrqzv2EttXze9aLYenuqN0exwssNSXpXbMCq3xlpMsoPKzL5jssRJBYm+ bLTH7UhI5bqq5xT47qYVmMgnt00lB0ISgnMN057UqjPk6N2xyAJM77yN0X9+7pSj8x3+ WmZiaS+8x1xMvKvTDgLLW0DV7Z7QGKYHml9mFCQSck7Rpr2RHtOK9b2xIUeG0/R5qqxl Ycuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 o15si12515054otp.314.2019.12.17.14.18.08 for ; Tue, 17 Dec 2019 14:18:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbfLQWSH (ORCPT ); Tue, 17 Dec 2019 17:18:07 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:57385 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726884AbfLQWSG (ORCPT ); Tue, 17 Dec 2019 17:18:06 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1N6KQZ-1haxi02lkf-016j9T; Tue, 17 Dec 2019 23:17:33 +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 23/27] compat_ioctl: move HDIO ioctl handling into drivers/ide Date: Tue, 17 Dec 2019 23:17:04 +0100 Message-Id: <20191217221708.3730997-24-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:/D1NP1hHpImcePmuJVorHaYd+oDnC0KYUns7AoRctoy/PRF56ag 9CgmMYuITFsdIlxRzHhQw8J1VfVcH6qQTsSkVNSAlsbyOfutTv/edqbEYMOgCnp0U2Iivk5 RQMhbBYtKLGmtbrm/n2NmsF6GdzfsRJe2Abcs0dmzn44BXZxnoMvi/3wH+hJDPM0jt6Kk2B Yc0JDsAWtxde8ZW02TWyA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:mSJF4exvfz4=:IusaUtG2jlMz6UDm/jSETr jkTYpg/QbJX4045dxbyAekcKRxji0NTwSyXV3k2jEd0N+iLvSLGbydTPfU7n+6APT7yGbwL+q Z+NMWhyp6cVzcv774FSjhYztehuFbu8mXbf8+URht4tTFtQk12D/SDb5Ysqrgbn8IUqnyoamL VpEVog+mtaT5tEr4k+AVwVjdc4d66QNblgdEGqsVqi8yMMYOoEbt+S0fOda3/ivT+M7vdlggI CWgbM40EGeunX6VOZ9MRReJBIU4asG98vjlgzegPQ1BjfrJFlBk8GNBbTU0Rwx+v5tzJriAcD 5UAykD51fauLiZMHIVibtrY+iifPIPSXK+KnaaeIzJc8m8QjMQd4h58IlX5YPWfrPHolJpnNa kTuOfF9PP8tUD4WkWP443G/EZGrcm/aTUd3471GLc6lJgSSKgjs4ATaDCmM4hrZbhxUz0J/VV oUz2DX0hXb2OfBCoy1aeFyxZx9QoYNnTMDStrQFS+rv7O0PQtwwOv8HdfbknFF3kxXR7rOAAw uTnd8+r/g0BfajCRelRjhBr503Xmwwo+ksDxn3aIkRVjhlFPsTxSutl3fVFLVGcVWLHtJEVLE dBH39ye5Ku2ygusz1U4maVq1Ct6Magh1iW8FdyoinP9bAhkxmaUk4QY8T3TUO8Eh1C7YFWSmT SmGVqc+bBjukHhVQhA7ZVXM09KJ2+FlbFWGk39XISFdIrJwAUsfNwdmRXTCZmSF9hLnXBVSuW auquuH2DQWeU7A7gssPRpz78B/qUIFnGRITAIH+ghbZsGGzfzOXTw9EkbILQfQoX2o8fOuWWv SMGfy7BT4zkosYRSgm7PcmVcixITBdfq2o09So9KrVKf+uqYOOcTech+yDS7wCtYc7bu3Gt46 OIAarc6M/aawxtr2aWJw== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Most of the HDIO ioctls are only used by the obsolete drivers/ide subsystem, these can be handled by changing ide_cmd_ioctl() to be aware of compat mode and doing the correct transformations in place and using it as both native and compat handlers for all drivers. The SCSI drivers implementing the same commands are already doing this in the drivers, so the compat_blkdev_driver_ioctl() function is no longer needed now. The BLKSECTSET and HDIO_GETGEO_BIG ioctls are not implemented in any driver any more and no longer need any conversion. Signed-off-by: Arnd Bergmann --- block/compat_ioctl.c | 75 ---------------------------------- drivers/ide/ide-cd.c | 15 +++---- drivers/ide/ide-disk.c | 1 + drivers/ide/ide-floppy_ioctl.c | 7 ++-- drivers/ide/ide-ioctls.c | 44 ++++++++++++-------- drivers/ide/ide-tape.c | 11 +++++ 6 files changed, 51 insertions(+), 102 deletions(-) -- 2.20.0 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 7cb534d6e767..765aa5357655 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c @@ -77,24 +77,6 @@ static int compat_hdio_getgeo(struct gendisk *disk, struct block_device *bdev, return ret; } -static int compat_hdio_ioctl(struct block_device *bdev, fmode_t mode, - unsigned int cmd, unsigned long arg) -{ - unsigned long __user *p; - int error; - - p = compat_alloc_user_space(sizeof(unsigned long)); - error = __blkdev_driver_ioctl(bdev, mode, - cmd, (unsigned long)p); - if (error == 0) { - unsigned int __user *uvp = compat_ptr(arg); - unsigned long v; - if (get_user(v, p) || put_user(v, uvp)) - error = -EFAULT; - } - return error; -} - struct compat_blkpg_ioctl_arg { compat_int_t op; compat_int_t flags; @@ -128,61 +110,6 @@ static int compat_blkpg_ioctl(struct block_device *bdev, fmode_t mode, #define BLKBSZSET_32 _IOW(0x12, 113, int) #define BLKGETSIZE64_32 _IOR(0x12, 114, int) -static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode, - unsigned cmd, unsigned long arg) -{ - switch (cmd) { - case HDIO_GET_UNMASKINTR: - case HDIO_GET_MULTCOUNT: - case HDIO_GET_KEEPSETTINGS: - case HDIO_GET_32BIT: - case HDIO_GET_NOWERR: - case HDIO_GET_DMA: - case HDIO_GET_NICE: - case HDIO_GET_WCACHE: - case HDIO_GET_ACOUSTIC: - case HDIO_GET_ADDRESS: - case HDIO_GET_BUSSTATE: - return compat_hdio_ioctl(bdev, mode, cmd, arg); - - /* - * No handler required for the ones below, we just need to - * convert arg to a 64 bit pointer. - */ - case BLKSECTSET: - /* - * 0x03 -- HD/IDE ioctl's used by hdparm and friends. - * Some need translations, these do not. - */ - case HDIO_GET_IDENTITY: - case HDIO_DRIVE_TASK: - case HDIO_DRIVE_CMD: - /* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */ - case 0x330: - arg = (unsigned long)compat_ptr(arg); - /* These intepret arg as an unsigned long, not as a pointer, - * so we must not do compat_ptr() conversion. */ - case HDIO_SET_MULTCOUNT: - case HDIO_SET_UNMASKINTR: - case HDIO_SET_KEEPSETTINGS: - case HDIO_SET_32BIT: - case HDIO_SET_NOWERR: - case HDIO_SET_DMA: - case HDIO_SET_PIO_MODE: - case HDIO_SET_NICE: - case HDIO_SET_WCACHE: - case HDIO_SET_ACOUSTIC: - case HDIO_SET_BUSSTATE: - case HDIO_SET_ADDRESS: - break; - default: - /* unknown ioctl number */ - return -ENOIOCTLCMD; - } - - return __blkdev_driver_ioctl(bdev, mode, cmd, arg); -} - /* Most of the generic ioctls are handled in the normal fallback path. This assumes the blkdev's low level compat_ioctl always returns ENOIOCTLCMD for unknown ioctls. */ @@ -293,8 +220,6 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) default: if (disk->fops->compat_ioctl) ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg); - if (ret == -ENOIOCTLCMD) - ret = compat_blkdev_driver_ioctl(bdev, mode, cmd, arg); return ret; } } diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 2de6e8ace957..284a7a5bad54 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1711,7 +1711,6 @@ static int idecd_ioctl(struct block_device *bdev, fmode_t mode, return ret; } -#ifdef CONFIG_COMPAT static int idecd_locked_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { @@ -1727,8 +1726,12 @@ static int idecd_locked_compat_ioctl(struct block_device *bdev, fmode_t mode, break; } - return cdrom_ioctl(&info->devinfo, bdev, mode, cmd, - (unsigned long)compat_ptr(arg)); + err = generic_ide_ioctl(info->drive, bdev, cmd, arg); + if (err == -EINVAL) + err = cdrom_ioctl(&info->devinfo, bdev, mode, cmd, + (unsigned long)compat_ptr(arg)); + + return err; } static int idecd_compat_ioctl(struct block_device *bdev, fmode_t mode, @@ -1742,7 +1745,6 @@ static int idecd_compat_ioctl(struct block_device *bdev, fmode_t mode, return ret; } -#endif static unsigned int idecd_check_events(struct gendisk *disk, unsigned int clearing) @@ -1765,9 +1767,8 @@ static const struct block_device_operations idecd_ops = { .open = idecd_open, .release = idecd_release, .ioctl = idecd_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = idecd_compat_ioctl, -#endif + .compat_ioctl = IS_ENABLED(CONFIG_COMPAT) ? + idecd_compat_ioctl : NULL, .check_events = idecd_check_events, .revalidate_disk = idecd_revalidate_disk }; diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 197912af5c2f..1d3407d7e095 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -794,4 +794,5 @@ const struct ide_disk_ops ide_ata_disk_ops = { .set_doorlock = ide_disk_set_doorlock, .do_request = ide_do_rw_disk, .ioctl = ide_disk_ioctl, + .compat_ioctl = ide_disk_ioctl, }; diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c index 4fd70f804d6f..39a790ac6cc3 100644 --- a/drivers/ide/ide-floppy_ioctl.c +++ b/drivers/ide/ide-floppy_ioctl.c @@ -329,10 +329,9 @@ int ide_floppy_compat_ioctl(ide_drive_t *drive, struct block_device *bdev, if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) err = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp); - /* - * there is no generic_ide_compat_ioctl(), that is handled - * through compat_blkdev_ioctl(). - */ + if (err == -ENOTTY) + err = generic_ide_ioctl(drive, bdev, cmd, arg); + out: mutex_unlock(&ide_floppy_ioctl_mutex); return err; diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c index d48c17003874..f6497c817493 100644 --- a/drivers/ide/ide-ioctls.c +++ b/drivers/ide/ide-ioctls.c @@ -3,11 +3,20 @@ * IDE ioctls handling. */ +#include #include #include #include #include +static int put_user_long(long val, unsigned long arg) +{ + if (in_compat_syscall()) + return put_user(val, (compat_long_t __user *)compat_ptr(arg)); + + return put_user(val, (long __user *)arg); +} + static const struct ide_ioctl_devset ide_ioctl_settings[] = { { HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit }, { HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, &ide_devset_keepsettings }, @@ -37,7 +46,7 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev, mutex_lock(&ide_setting_mtx); err = ds->get(drive); mutex_unlock(&ide_setting_mtx); - return err >= 0 ? put_user(err, (long __user *)arg) : err; + return err >= 0 ? put_user_long(err, arg) : err; set_val: if (bdev != bdev->bd_contains) @@ -56,7 +65,7 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev, EXPORT_SYMBOL_GPL(ide_setting_ioctl); static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd, - unsigned long arg) + void __user *argp) { u16 *id = NULL; int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142; @@ -77,7 +86,7 @@ static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd, memcpy(id, drive->id, size); ata_id_to_hd_driveid(id); - if (copy_to_user((void __user *)arg, id, size)) + if (copy_to_user(argp, id, size)) rc = -EFAULT; kfree(id); @@ -87,10 +96,10 @@ static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd, static int ide_get_nice_ioctl(ide_drive_t *drive, unsigned long arg) { - return put_user((!!(drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) + return put_user_long((!!(drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) << IDE_NICE_DSC_OVERLAP) | (!!(drive->dev_flags & IDE_DFLAG_NICE1) - << IDE_NICE_1), (long __user *)arg); + << IDE_NICE_1), arg); } static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg) @@ -115,7 +124,7 @@ static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg) return 0; } -static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg) +static int ide_cmd_ioctl(ide_drive_t *drive, void __user *argp) { u8 *buf = NULL; int bufsize = 0, err = 0; @@ -123,7 +132,7 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg) struct ide_cmd cmd; struct ide_taskfile *tf = &cmd.tf; - if (NULL == (void *) arg) { + if (NULL == argp) { struct request *rq; rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, 0); @@ -135,7 +144,7 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg) return err; } - if (copy_from_user(args, (void __user *)arg, 4)) + if (copy_from_user(args, argp, 4)) return -EFAULT; memset(&cmd, 0, sizeof(cmd)); @@ -181,19 +190,18 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg) args[1] = tf->error; args[2] = tf->nsect; abort: - if (copy_to_user((void __user *)arg, &args, 4)) + if (copy_to_user(argp, &args, 4)) err = -EFAULT; if (buf) { - if (copy_to_user((void __user *)(arg + 4), buf, bufsize)) + if (copy_to_user((argp + 4), buf, bufsize)) err = -EFAULT; kfree(buf); } return err; } -static int ide_task_ioctl(ide_drive_t *drive, unsigned long arg) +static int ide_task_ioctl(ide_drive_t *drive, void __user *p) { - void __user *p = (void __user *)arg; int err = 0; u8 args[7]; struct ide_cmd cmd; @@ -237,6 +245,10 @@ int generic_ide_ioctl(ide_drive_t *drive, struct block_device *bdev, unsigned int cmd, unsigned long arg) { int err; + void __user *argp = (void __user *)arg; + + if (in_compat_syscall()) + argp = compat_ptr(arg); err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_ioctl_settings); if (err != -EOPNOTSUPP) @@ -247,7 +259,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct block_device *bdev, case HDIO_GET_IDENTITY: if (bdev != bdev->bd_contains) return -EINVAL; - return ide_get_identity_ioctl(drive, cmd, arg); + return ide_get_identity_ioctl(drive, cmd, argp); case HDIO_GET_NICE: return ide_get_nice_ioctl(drive, arg); case HDIO_SET_NICE: @@ -265,11 +277,11 @@ int generic_ide_ioctl(ide_drive_t *drive, struct block_device *bdev, case HDIO_DRIVE_CMD: if (!capable(CAP_SYS_RAWIO)) return -EACCES; - return ide_cmd_ioctl(drive, arg); + return ide_cmd_ioctl(drive, argp); case HDIO_DRIVE_TASK: if (!capable(CAP_SYS_RAWIO)) return -EACCES; - return ide_task_ioctl(drive, arg); + return ide_task_ioctl(drive, argp); case HDIO_DRIVE_RESET: if (!capable(CAP_SYS_ADMIN)) return -EACCES; @@ -277,7 +289,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct block_device *bdev, case HDIO_GET_BUSSTATE: if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (put_user(BUSSTATE_ON, (long __user *)arg)) + if (put_user_long(BUSSTATE_ON, arg)) return -EFAULT; return 0; case HDIO_SET_BUSSTATE: diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 3e7482695f77..6f26634b22bb 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1945,11 +1945,22 @@ static int idetape_ioctl(struct block_device *bdev, fmode_t mode, return err; } +static int idetape_compat_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long arg) +{ + if (cmd == 0x0340 || cmd == 0x350) + arg = (unsigned long)compat_ptr(arg); + + return idetape_ioctl(bdev, mode, cmd, arg); +} + static const struct block_device_operations idetape_block_ops = { .owner = THIS_MODULE, .open = idetape_open, .release = idetape_release, .ioctl = idetape_ioctl, + .compat_ioctl = IS_ENABLED(CONFIG_COMPAT) ? + idetape_compat_ioctl : NULL, }; static int ide_tape_probe(ide_drive_t *drive)