Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jun 2021 01:38:07 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0379dc900e53 - stable/13 - kern_exec.c: Add execve_nosetid() helper
Message-ID:  <202106130138.15D1c7kP038236@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0379dc900e5304d3915ca82110445f2bcc415fcb

commit 0379dc900e5304d3915ca82110445f2bcc415fcb
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-01-14 13:36:15 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-06-13 01:22:32 +0000

    kern_exec.c: Add execve_nosetid() helper
    
    (cherry picked from commit 19e6043a443ea51207786b85c8d62d070ec36005)
---
 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 3de6ac565db5..1df422dec08e 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -353,6 +353,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.
@@ -639,11 +649,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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106130138.15D1c7kP038236>