The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=450fe67d19eb2ea8e27109214ff21064fdcf808c

commit 450fe67d19eb2ea8e27109214ff21064fdcf808c
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-06-17 19:06:50 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-06-21 11:46:52 +0000

    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
---
 sys/kern/kern_exec.c | 20 ++++++++++++++++----
 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_ */

Reply via email to