From patchwork Wed Aug 16 02:31:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 9902835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5F3BC602C9 for ; Wed, 16 Aug 2017 02:32:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50F042876E for ; Wed, 16 Aug 2017 02:32:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45EE7287A1; Wed, 16 Aug 2017 02:32:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0772876E for ; Wed, 16 Aug 2017 02:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463AbdHPCbb (ORCPT ); Tue, 15 Aug 2017 22:31:31 -0400 Received: from icp-osb-irony-out4.external.iinet.net.au ([203.59.1.220]:7064 "EHLO icp-osb-irony-out4.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753434AbdHPCb2 (ORCPT ); Tue, 15 Aug 2017 22:31:28 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AZBABDrZNZ/0Tj/dxeGwEBAQMBAQEJAQEBg1qBeZ4jOAEBAQEBAQaBCCIRkSuEXIISHIUrAoQ2QRYBAgEBAQEBAQFrKIUZBiMEUhAYAQcFAhgOAgJHEAYTiiIMrHKBbDoiAotFATGBC4IdggKBBYJgineCYQWSHo4flECLXYZ8SJVQJggpgQpTLwqFYByBdDM2h0MrghQBAQE X-IPAS-Result: A2AZBABDrZNZ/0Tj/dxeGwEBAQMBAQEJAQEBg1qBeZ4jOAEBAQEBAQaBCCIRkSuEXIISHIUrAoQ2QRYBAgEBAQEBAQFrKIUZBiMEUhAYAQcFAhgOAgJHEAYTiiIMrHKBbDoiAotFATGBC4IdggKBBYJgineCYQWSHo4flECLXYZ8SJVQJggpgQpTLwqFYByBdDM2h0MrghQBAQE X-IronPort-AV: E=Sophos;i="5.41,380,1498492800"; d="scan'208";a="285016150" Received: from unknown (HELO pluto.themaw.net) ([220.253.227.68]) by icp-osb-irony-out4.iinet.net.au with ESMTP; 16 Aug 2017 10:31:26 +0800 Subject: [PATCH 3/5] autofs: use AUTOFS_DEV_IOCTL_SIZE From: Ian Kent To: Andrew Morton Cc: linux-fsdevel , Tomohiro Kusumi , autofs mailing list , Kernel Mailing List Date: Wed, 16 Aug 2017 10:31:25 +0800 Message-ID: <150285068577.4670.2599968823770600622.stgit@pluto.themaw.net> In-Reply-To: <150285067347.4670.11494624644273072003.stgit@pluto.themaw.net> References: <150285067347.4670.11494624644273072003.stgit@pluto.themaw.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tomohiro Kusumi Use a macro which defines misc-dev ioctl parameter size (excluding a path beyond &path[0]) since it's been used to initialize and copy this structure ever since it first appeared in 8d7b48e0 in 2008. (or simply get rid of this if this is just unnecessary abstraction when all it needs is sizeof(struct autofs_dev_ioctl)) Edit: imk That's a good point but I'd prefer to keep the macro define. End edit: imk Signed-off-by: Tomohiro Kusumi Signed-off-by: Ian Kent --- fs/autofs4/dev-ioctl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c index ea8b3a1cddd2..b8b66d55266d 100644 --- a/fs/autofs4/dev-ioctl.c +++ b/fs/autofs4/dev-ioctl.c @@ -97,13 +97,13 @@ static struct autofs_dev_ioctl * { struct autofs_dev_ioctl tmp, *res; - if (copy_from_user(&tmp, in, sizeof(tmp))) + if (copy_from_user(&tmp, in, AUTOFS_DEV_IOCTL_SIZE)) return ERR_PTR(-EFAULT); - if (tmp.size < sizeof(tmp)) + if (tmp.size < AUTOFS_DEV_IOCTL_SIZE) return ERR_PTR(-EINVAL); - if (tmp.size > (PATH_MAX + sizeof(tmp))) + if (tmp.size > AUTOFS_DEV_IOCTL_SIZE + PATH_MAX) return ERR_PTR(-ENAMETOOLONG); res = memdup_user(in, tmp.size); @@ -133,8 +133,8 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param) goto out; } - if (param->size > sizeof(*param)) { - err = invalid_str(param->path, param->size - sizeof(*param)); + if (param->size > AUTOFS_DEV_IOCTL_SIZE) { + err = invalid_str(param->path, param->size - AUTOFS_DEV_IOCTL_SIZE); if (err) { pr_warn( "path string terminator missing for cmd(0x%08x)\n", @@ -451,7 +451,7 @@ static int autofs_dev_ioctl_requester(struct file *fp, dev_t devid; int err = -ENOENT; - if (param->size <= sizeof(*param)) { + if (param->size <= AUTOFS_DEV_IOCTL_SIZE) { err = -EINVAL; goto out; } @@ -539,7 +539,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, unsigned int devid, magic; int err = -ENOENT; - if (param->size <= sizeof(*param)) { + if (param->size <= AUTOFS_DEV_IOCTL_SIZE) { err = -EINVAL; goto out; }