kern_exec.c: Add execve_nosetid() helper

(cherry picked from commit 19e6043a44)
This commit is contained in:
Konstantin Belousov 2021-01-14 15:36:15 +02:00
parent a3a907abbf
commit 0379dc900e

View file

@ -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;