From nobody Wed Apr 27 23:27:53 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A2A051AA9091; Wed, 27 Apr 2022 23:27:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KpZfy2Pw6z4YDq; Wed, 27 Apr 2022 23:27:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651102074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3FajlHiAMkNguSyoJ/dVZ5bB4jcGdr5Qj45mHAWjx+8=; b=v9PEIRH59HWYfBh2dmqrHVPrXFeUkcF19l0WuygqDino4BzJWcRBoN7JR9gL/PBdCH2U2S PhGhdmxLTFCR94uGUkbGgai/BRfv0TVOn6PMHBx0jqKvloeTT+YcvRO7qYgd+CF4RLIdVR wtpOTrwFBYn2z2Uq817+2YNO7AwHm+huI4iNexe0x/kzujU5/DZzU03JsZvmKy8kPewjlm Xdaz6iDylaiGwEHPe5lhBxBZXJkw/XWkwdr+Pyk9O14kbA6sf6sPFAt8J0s/DrSPjG1kZY xhA2dY6coi/M1N9JuzKKfZw8QUjGNCTQeD1VTRgZGm8hGqg8NwnLPsEugEaqMw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0E88655D6; Wed, 27 Apr 2022 23:27:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23RNRrK1071941; Wed, 27 Apr 2022 23:27:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RNRr4H071940; Wed, 27 Apr 2022 23:27:53 GMT (envelope-from git) Date: Wed, 27 Apr 2022 23:27:53 GMT Message-Id: <202204272327.23RNRr4H071940@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d1df34736888 - main - kern_procctl: add possibility to take stop_all_proc_block() around exec List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d1df34736888f43e8fe1cdc460eac134d625c777 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651102074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3FajlHiAMkNguSyoJ/dVZ5bB4jcGdr5Qj45mHAWjx+8=; b=fCHjg3zK1CxO+S6/zrR2mPIDLCuyoDtEVXmuZKUdp2ym0U1P1yiyKhexU6Px4oXZVY50qR kDq3cLYJWi52mxq5bitYX2VYQbblkP2DPzVt5o0wAiyv+NgtGUYPWV3boNnfoyrJXorySF 7ZOPzThmbrV+gPqSNkz8t/KOzKhQoNsFimMwPmjGYU9oZCnI2OGYse7apJWgFy4PmXMDuH wd6zwpe0nQIsEKXEx9Ek4qrFhwHtezNamRMLpIawqLvGueZVym1SWLBmn8SRk0q/1LXAuR g8aeNHGPNvpvOWRGk//35k4DufcW8Fo8sHWuh1bOgO5xF2b/zxdT9C+n+zFEDQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651102074; a=rsa-sha256; cv=none; b=r06UTehMNn6kv6QrR9ytA6UX/j3oVrDzCb40PTQu04MOMO24L8K2CEmOpv6Ah5mqoSZe4D whTUaeGK/KWuWcfClz544vJurrT3Wdd2CNtuzZXluPTwdjLp/zR75pU1P9nLs/vhXR/eRS 5lDAWiGe3xlIT7WUtRG3BauZItXh6uBZoyBVvC1HeENQRiBRg7usvb1sksb1wCRPxSA0p9 J7sx6Tm9qh+MPUODf48vccnPlWezxR9aoyymlU2yIeA7s7X4ky0o5hdBQFuAZzBUixlyoQ /0Y7dQBhUJ7tpbLokOMzBNwl0JgoYJ85yu54yKANTVrVcxvYUN3yJ34FqvVxEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d1df34736888f43e8fe1cdc460eac134d625c777 commit d1df34736888f43e8fe1cdc460eac134d625c777 Author: Konstantin Belousov AuthorDate: 2022-04-27 21:18:34 +0000 Commit: Konstantin Belousov 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); }