From owner-dev-commits-src-main@freebsd.org Sun Jun 6 19:25:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4803463BEB6; Sun, 6 Jun 2021 19:25:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fymgf1LMYz3mJZ; Sun, 6 Jun 2021 19:25:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 164581109; Sun, 6 Jun 2021 19:25:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 156JPoJ8045012; Sun, 6 Jun 2021 19:25:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 156JPole045011; Sun, 6 Jun 2021 19:25:50 GMT (envelope-from git) Date: Sun, 6 Jun 2021 19:25:50 GMT Message-Id: <202106061925.156JPole045011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 19e6043a443e - main - kern_exec.c: Add execve_nosetid() helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 19e6043a443ea51207786b85c8d62d070ec36005 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2021 19:25:50 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=19e6043a443ea51207786b85c8d62d070ec36005 commit 19e6043a443ea51207786b85c8d62d070ec36005 Author: Konstantin Belousov AuthorDate: 2021-01-14 13:36:15 +0000 Commit: Konstantin Belousov CommitDate: 2021-06-06 18:42:41 +0000 kern_exec.c: Add execve_nosetid() helper Reviewed by: dchagin Tested by: trasz MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28154 --- sys/kern/kern_exec.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 50451c1242eb..356c30ee030c 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -355,6 +355,16 @@ kern_execve(struct thread *td, struct image_args *args, struct mac *mac_p, return (do_execve(td, args, mac_p, oldvmspace)); } +static void +execve_nosetid(struct image_params *imgp) +{ + imgp->credential_setid = false; + if (imgp->newcred != NULL) { + crfree(imgp->newcred); + imgp->newcred = NULL; + } +} + /* * In-kernel implementation of execve(). All arguments are assumed to be * userspace pointers from the passed thread. @@ -643,11 +653,7 @@ interpret: vput(newtextvp); vm_object_deallocate(imgp->object); imgp->object = NULL; - imgp->credential_setid = false; - if (imgp->newcred != NULL) { - crfree(imgp->newcred); - imgp->newcred = NULL; - } + execve_nosetid(imgp); imgp->execpath = NULL; free(imgp->freepath, M_TEMP); imgp->freepath = NULL;