From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D7AFC47404 for ; Wed, 9 Oct 2019 19:15:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE733218DE for ; Wed, 9 Oct 2019 19:15:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732588AbfJITPY (ORCPT ); Wed, 9 Oct 2019 15:15:24 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:47711 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730490AbfJITLH (ORCPT ); Wed, 9 Oct 2019 15:11:07 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MWAjC-1ibYVn29tK-00XaSj; Wed, 09 Oct 2019 21:11:05 +0200 From: Arnd Bergmann To: Al Viro Cc: linux-kernel@vger.kernel.org, y2038@lists.linaro.org, linux-fsdevel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v6 06/43] compat_sys_ioctl(): make parallel to do_vfs_ioctl() Date: Wed, 9 Oct 2019 21:10:06 +0200 Message-Id: <20191009191044.308087-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191009190853.245077-1-arnd@arndb.de> References: <20191009190853.245077-1-arnd@arndb.de> MIME-Version: 1.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Nw7mra9EcDM0hyRy1aXmmyewFrGWUoxmXytB3EpmNSzTBaJUmrvVl2jaJ lmKzKVf7kOns6C8kIXlBXPCgy4zu72SJuhplCEZ6AIQDVPIFVHPLQHsuzevxWExlmpBIP0A/b rvNVT6WH8mNzOMTpTDOQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro Handle ioctls that might be handled without reaching ->ioctl() in native case on the top level there. The counterpart of vfs_ioctl() (i.e. calling ->unlock_ioctl(), etc.) left as-is; eventually that would turn simply into the call of ->compat_ioctl(), but that'll take more work. Once that is done, we can move the remains of compat_sys_ioctl() into fs/ioctl.c and finally bury fs/compat_ioctl.c. Signed-off-by: Al Viro Signed-off-by: Arnd Bergmann --- fs/compat_ioctl.c | 63 +++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index ce995d4fa1f4..ecbd5254b547 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -487,19 +487,7 @@ static unsigned int ioctl_pointer[] = { /* compatible ioctls first */ /* Little t */ COMPATIBLE_IOCTL(TIOCOUTQ) -/* Little f */ -COMPATIBLE_IOCTL(FIOCLEX) -COMPATIBLE_IOCTL(FIONCLEX) -COMPATIBLE_IOCTL(FIOASYNC) -COMPATIBLE_IOCTL(FIONBIO) -COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */ -COMPATIBLE_IOCTL(FS_IOC_FIEMAP) -/* 0x00 */ -COMPATIBLE_IOCTL(FIBMAP) -COMPATIBLE_IOCTL(FIGETBSZ) /* 'X' - originally XFS but some now in the VFS */ -COMPATIBLE_IOCTL(FIFREEZE) -COMPATIBLE_IOCTL(FITHAW) COMPATIBLE_IOCTL(FITRIM) #ifdef CONFIG_BLOCK /* Big S */ @@ -971,19 +959,39 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, if (error) goto out_fput; - /* - * To allow the compat_ioctl handlers to be self contained - * we need to check the common ioctls here first. - * Just handle them with the standard handlers below. - */ switch (cmd) { + /* these are never seen by ->ioctl(), no argument or int argument */ case FIOCLEX: case FIONCLEX: + case FIFREEZE: + case FITHAW: + case FICLONE: + goto do_ioctl; + /* these are never seen by ->ioctl(), pointer argument */ case FIONBIO: case FIOASYNC: case FIOQSIZE: - break; - + case FS_IOC_FIEMAP: + case FIGETBSZ: + case FICLONERANGE: + case FIDEDUPERANGE: + goto found_handler; + /* + * The next group is the stuff handled inside file_ioctl(). + * For regular files these never reach ->ioctl(); for + * devices, sockets, etc. they do and one (FIONREAD) is + * even accepted in some cases. In all those cases + * argument has the same type, so we can handle these + * here, shunting them towards do_vfs_ioctl(). + * ->compat_ioctl() will never see any of those. + */ + /* pointer argument, never actually handled by ->ioctl() */ + case FIBMAP: + goto found_handler; + /* handled by some ->ioctl(); always a pointer to int */ + case FIONREAD: + goto found_handler; + /* these two get messy on amd64 due to alignment differences */ #if defined(CONFIG_X86_64) case FS_IOC_RESVSP_32: case FS_IOC_RESVSP64_32: @@ -992,23 +1000,8 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, #else case FS_IOC_RESVSP: case FS_IOC_RESVSP64: - error = ioctl_preallocate(f.file, compat_ptr(arg)); - goto out_fput; -#endif - - case FICLONE: - goto do_ioctl; - case FICLONERANGE: - case FIDEDUPERANGE: - case FS_IOC_FIEMAP: - case FIGETBSZ: goto found_handler; - - case FIBMAP: - case FIONREAD: - if (S_ISREG(file_inode(f.file)->i_mode)) - break; - /*FALL THROUGH*/ +#endif default: if (f.file->f_op->compat_ioctl) { -- 2.20.0