aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-01-14 13:36:15 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-06-06 18:42:41 +0000
commit19e6043a443ea51207786b85c8d62d070ec36005 (patch)
tree9ad9a4f2773e696975e181b0dfdd297bcff22f78
parent66e73ce7371b717b8dd0dfd6e3deeacfa95e6f8b (diff)
downloadsrc-19e6043a443ea51207786b85c8d62d070ec36005.tar.gz
src-19e6043a443ea51207786b85c8d62d070ec36005.zip
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
-rw-r--r--sys/kern/kern_exec.c16
1 files 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;