From patchwork Fri Mar 26 14:38:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12166917 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 A6172C433E6 for ; Fri, 26 Mar 2021 14:40:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75AD161A18 for ; Fri, 26 Mar 2021 14:40:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbhCZOkJ (ORCPT ); Fri, 26 Mar 2021 10:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230432AbhCZOjh (ORCPT ); Fri, 26 Mar 2021 10:39:37 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ACBBC0613AA; Fri, 26 Mar 2021 07:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=/jKV/Gy/+fs6Gymuc4/KOBeEW5L+yZioO5xj7LGmOvk=; b=btDOhdv9dVGM1bGt10zskeqyPc IJAjY5J3M0V2Ssi7NNgeil59DhlO7E6oivZQivAq28Yc/KdK5u93ZUzDZoVMRBaqlxf7Hzy6oPSFM Gc7pPPsejd0I1/ziak6y+NLOOzg/pHXRIHbvit+wD4AvJYsnF0HfOWu5pwz5GIOWq8HdAkje6X7N3 TUJFPYXDjR9Q79HD9E3nT09I7Kla49p7nnSeVcJQ8d4upVPhE6fnygZAebM1joGOA27iFFm/o0+/B mCSb1li1OrgAlMOR/k7wZ8wo7QJW5gJo0hZgzjjtivcofkbuzF9JLCQDLtOI6vcJLBXrOv9eI7Fih ZqqU60vg==; Received: from [213.208.157.35] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lPncI-005U87-0D; Fri, 26 Mar 2021 14:39:14 +0000 From: Christoph Hellwig To: "Eric W. Biederman" , Al Viro Cc: Arnd Bergmann , Brian Gerst , Luis Chamberlain , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] exec: move the call to getname_flags into do_execveat Date: Fri, 26 Mar 2021 15:38:31 +0100 Message-Id: <20210326143831.1550030-5-hch@lst.de> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210326143831.1550030-1-hch@lst.de> References: <20210326143831.1550030-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Remove the duplicated copying of the pathname into the common helper. Signed-off-by: Christoph Hellwig Reviewed-by: Arnd Bergmann --- fs/exec.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index b34c1eb9e7ad8e..5c0dd8f85fe7b5 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1843,13 +1843,16 @@ static int bprm_execve(struct linux_binprm *bprm, return retval; } -static int do_execveat(int fd, struct filename *filename, +static int do_execveat(int fd, const char __user *pathname, const char __user *const __user *argv, const char __user *const __user *envp, int flags) { + int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0; + struct filename *filename; struct linux_binprm *bprm; int retval; + filename = getname_flags(pathname, lookup_flags, NULL); if (IS_ERR(filename)) return PTR_ERR(filename); @@ -1993,7 +1996,7 @@ SYSCALL_DEFINE3(execve, const char __user *const __user *, argv, const char __user *const __user *, envp) { - return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0); + return do_execveat(AT_FDCWD, filename, argv, envp, 0); } SYSCALL_DEFINE5(execveat, @@ -2002,9 +2005,5 @@ SYSCALL_DEFINE5(execveat, const char __user *const __user *, envp, int, flags) { - int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0; - - return do_execveat(fd, - getname_flags(filename, lookup_flags, NULL), - argv, envp, flags); + return do_execveat(fd, filename, argv, envp, flags); }