Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5188052ybi; Tue, 30 Jul 2019 15:44:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxv9VNQjT9VJqAh55/pmSia0u5WYBYyGC3r18CBVYoYI3aEp8KEF0kZ/dBr1kxes6CJ9FYr X-Received: by 2002:a63:4041:: with SMTP id n62mr39708700pga.312.1564526682549; Tue, 30 Jul 2019 15:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564526682; cv=none; d=google.com; s=arc-20160816; b=x5AG2froCTisswatQZ48KkwfWrwWKF6nW35eYK3lP8FLVssL9rcXGGeP7X/bxNLWbs u66nzFnnlkYEB2/fLe8M7CizVmaMwlRnGbsTUwWwAXAhUIzQ7//HTNU/xvIZ4Xw0tGOO lF00QZ3Ti3XAG1nf7/xPh7OEPBEthhvYZkjx5BmG73j3GLASWakFIYLTDRjmL33UX634 5kPlyTX4KLCExFoJjqujBbrPRzPqQ6PKa840gKQqCN04uVfVC3h+xMPIgGYqmt5G+dz9 DtppUfC1D9ROjtmXtJFs1zd6e1wZJRpowqp1Ierfm+KbGlczZ3YJ+Rs+XXCea5wx0X8+ YAFw== 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=UIlrObPZloCfITjqGLiG/uP/S2xiC5f1WiC64PmjDyM=; b=oOUM2l7vy2oRqmA1pMfLCfD2Ig3LKIRQXbQjuAE4J4zPGC/0XspUz7ZpjFD7m5uyjm 6P46lzi2vnXYMwl1AyskLR2Chiw/ntYhe68s6C228b+A6o+nU9gGOOnGetS/H80UCarc 16EaaEL5p7MjWD3DQT9MmPkfcnHNmEk/PBpv1cDvt8BnFZjvhse5RlfOzopNt/nBIWOH HMkMad8HgwAcpY0HSj7QMw0EWX9dfW/9ajz0azI1U20QkmO15jfZQY5mLtzTIkTiQN9T rBC8HAXT+nrGAcvviYHn5KHG1AkcQATpLqYGrkKAfmPIhEO5BdQlKHY6+YScWk6VvPnt L55g== 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 bd11si27044283plb.184.2019.07.30.15.44.27; Tue, 30 Jul 2019 15:44:42 -0700 (PDT) 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 S1729304AbfG3T1x (ORCPT + 99 others); Tue, 30 Jul 2019 15:27:53 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:46957 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbfG3T1w (ORCPT ); Tue, 30 Jul 2019 15:27:52 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MBDSg-1i5DlA14H8-00CikT; Tue, 30 Jul 2019 21:27:50 +0200 From: Arnd Bergmann To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v5 06/29] compat_sys_ioctl(): make parallel to do_vfs_ioctl() Date: Tue, 30 Jul 2019 21:25:17 +0200 Message-Id: <20190730192552.4014288-7-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190730192552.4014288-1-arnd@arndb.de> References: <20190730192552.4014288-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding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lMI+A== 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 0a748324f96f..399287b277dd 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 */ @@ -974,19 +962,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: @@ -995,23 +1003,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