Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jun 2022 19:36:51 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: 034c2787d229 - stable/13 - kern_procctl: add possibility to take stop_all_proc_block() around exec
Message-ID:  <202206241936.25OJapkP084084@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=034c2787d22975f3cc3ba11d4b3a72271ac268db

commit 034c2787d22975f3cc3ba11d4b3a72271ac268db
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-04-27 21:18:34 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-06-24 14:45:45 +0000

    kern_procctl: add possibility to take stop_all_proc_block() around exec
    
    (cherry picked from commit d1df34736888f43e8fe1cdc460eac134d625c777)
---
 sys/kern/kern_procctl.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c
index bc7ba14a6f97..1a9f17de2d7a 100644
--- a/sys/kern/kern_procctl.c
+++ b/sys/kern/kern_procctl.c
@@ -319,6 +319,15 @@ reap_kill_subtree(struct thread *td, struct proc *p, struct proc *reaper,
 	}
 }
 
+static bool
+reap_kill_sapblk(struct thread *td __unused, void *data)
+{
+	struct procctl_reaper_kill *rk;
+
+	rk = data;
+	return ((rk->rk_flags & REAPER_KILL_CHILDREN) == 0);
+}
+
 static int
 reap_kill(struct thread *td, struct proc *p, void *data)
 {
@@ -737,6 +746,7 @@ struct procctl_cmd_info {
 	int copyin_sz;
 	int copyout_sz;
 	int (*exec)(struct thread *, struct proc *, void *);
+	bool (*sapblk)(struct thread *, void *);
 };
 static const struct procctl_cmd_info procctl_cmds_info[] = {
 	[PROC_SPROTECT] =
@@ -777,7 +787,8 @@ static const struct procctl_cmd_info procctl_cmds_info[] = {
 	      .need_candebug = false,
 	      .copyin_sz = sizeof(struct procctl_reaper_kill),
 	      .copyout_sz = sizeof(struct procctl_reaper_kill),
-	      .exec = reap_kill, .copyout_on_error = true, },
+	      .exec = reap_kill, .copyout_on_error = true,
+	      .sapblk = reap_kill_sapblk, },
 	[PROC_TRACE_CTL] =
 	    { .lock_tree = PCTL_SLOCKED, .one_proc = false,
 	      .esrch_is_einval = false, .no_nonnull_data = false,
@@ -930,12 +941,20 @@ kern_procctl(struct thread *td, idtype_t idtype, id_t id, int com, void *data)
 	struct proc *p;
 	const struct procctl_cmd_info *cmd_info;
 	int error, first_error, ok;
+	bool sapblk;
 
 	MPASS(com > 0 && com < nitems(procctl_cmds_info));
 	cmd_info = &procctl_cmds_info[com];
 	if (idtype != P_PID && cmd_info->one_proc)
 		return (EINVAL);
 
+	sapblk = false;
+	if (cmd_info->sapblk != NULL) {
+		sapblk = cmd_info->sapblk(td, data);
+		if (sapblk)
+			stop_all_proc_block();
+	}
+
 	switch (cmd_info->lock_tree) {
 	case PCTL_XLOCKED:
 		sx_xlock(&proctree_lock);
@@ -1024,5 +1043,7 @@ kern_procctl(struct thread *td, idtype_t idtype, id_t id, int com, void *data)
 	default:
 		break;
 	}
+	if (sapblk)
+		stop_all_proc_unblock();
 	return (error);
 }



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