git: d1df34736888 - main - kern_procctl: add possibility to take stop_all_proc_block() around exec
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Apr 2022 23:27:53 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d1df34736888f43e8fe1cdc460eac134d625c777 commit d1df34736888f43e8fe1cdc460eac134d625c777 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-04-27 21:18:34 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-04-27 23:27:35 +0000 kern_procctl: add possibility to take stop_all_proc_block() around exec stop_allo_proc_block() must be taken before proctree_lock. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35014 --- 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); }