diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2026-06-17 19:06:50 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2026-06-21 11:46:52 +0000 |
| commit | 450fe67d19eb2ea8e27109214ff21064fdcf808c (patch) | |
| tree | 6b2103a68f63c98a93244a8d021522fcbb965b5d | |
| parent | e1a84b7708c2514769625c2af6c5034694013b6a (diff) | |
execve_block_pass(9): a helper to wait for the execblock to pass
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D57497
| -rw-r--r-- | sys/kern/kern_exec.c | 20 | ||||
| -rw-r--r-- | sys/sys/imgact.h | 1 |
2 files changed, 17 insertions, 4 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 7c25dc60960d..15570eee4c37 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -441,6 +441,21 @@ execve_unblock(struct thread *td, struct proc *p) } } +void +execve_block_pass(struct thread *td) +{ + struct proc *p; + + MPASS(td == curthread); + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + + while (p->p_execblock != 0) { + p->p_flag |= P_INEXEC_WAIT; + msleep(&p->p_execblock, &p->p_mtx, 0, "exeblk", 0); + } +} + /* * In-kernel implementation of execve(). All arguments are assumed to be * userspace pointers from the passed thread. @@ -496,10 +511,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, PROC_LOCK(p); KASSERT((p->p_flag & P_INEXEC) == 0, ("%s(): process already has P_INEXEC flag", __func__)); - while (p->p_execblock != 0) { - p->p_flag |= P_INEXEC_WAIT; - msleep(&p->p_execblock, &p->p_mtx, 0, "exeblk", 0); - } + execve_block_pass(td); p->p_flag |= P_INEXEC; PROC_UNLOCK(p); diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h index dbb76a1d9b93..bf0453beec1f 100644 --- a/sys/sys/imgact.h +++ b/sys/sys/imgact.h @@ -127,6 +127,7 @@ void post_execve(struct thread *td, int error, struct vmspace *oldvmspace); bool execve_block(struct thread *td, struct proc *p); void execve_block_wait(struct thread *td, struct proc *p); void execve_unblock(struct thread *td, struct proc *p); +void execve_block_pass(struct thread *td); #endif #endif /* !_SYS_IMGACT_H_ */ |
