From nobody Mon Jun 29 19:25:51 2026 X-Original-To: dev-commits-src-branches@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 4gpx8H4fmvz6jjZK for ; Mon, 29 Jun 2026 19:25:51 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gpx8H1WDHz40Ng for ; Mon, 29 Jun 2026 19:25:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782761151; 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=WXkcFh6WMeWUBQbcr1ZaAQKH4RgoZ14NFSEtuzgCM9I=; b=TkEVJeuyJcwOV84duDM8ZR2xqAmIj/frgqBSQPoS/cE48W5M4c18oyc5i95QOB7lojr3cv NpPr4TvTf2tZ/3Er17EZso+8xggZW2tfR+k1zbitWOCym7VgNlCpv3mOQaGgdmMTAsjDKM feejVra9DBG09crrHel2OGLl0HzYJsJ018vBvNwe3tv8IxRcrl3/9HG3kaAzp3koaG0HAB 77hqB/SeMhvjpIA8Qp6qIqWVACTNvCbWmxWuXUJTDDK9VbW9CXB4Y2vGXapBzT2FO4koNJ vo0fsdyzSCAh/LcYuHD/Vgk7NxwgTGVOWzsli9eCskvs3WyJ+Ctm1Fjcb+gAlg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782761151; a=rsa-sha256; cv=none; b=TOZ6Sfj63UtqTSUhjGWOBY5PFM5KNvaHFhdDr2WomIa6EY4B1gMtgoED7AV+KvIXF+MS/6 Uq/o5xKqkT0++vNvRQr5rrS4bTuyXhZI5ONWnkiC75w2+vK4di0xh7MHBxgtWeqjokpcgv Hdy1KY0xCbCGwh/fksuC6RqfJVSa3tR7xw74GRGKh+pU2uHetX+JgKRW1cXue6OJzHVgT/ dtk4KOQJzzycbcNMx3hkhuhxidI7Dkt/2Exn87m3zUabX67WbHaTmj7eMdkfyjea563W9B YAvqmSNyKuZJRj0pooSn8sgZl96TsR4FBJQ0itUSWkInNK6b1n3QHqPQC1l3Dg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782761151; 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=WXkcFh6WMeWUBQbcr1ZaAQKH4RgoZ14NFSEtuzgCM9I=; b=fR2LUmXUu5+v0pt5E9lwb3nqFEe6GoPYhdT8W3dvvQi8eOVV/uoB3YVV6jXdGFEOxeNgxg LXLFdZ0N2GcABFqS3axap+ESe0RL20LA4djMWLQNqaxPtb9k+trJWco/5GUH5sCNTU2QNv tt4BhGdLUZakwfeob15cf1UxhqjQrr9CsSqdM0l+A/N4EPKU+KdWBqkSTla6LyxI7M0i4y dUM2VFzcOqCUoDdNFnLrus4laYK7RlszPXVUJd8ZEwVV//OofBfYNJXbSgUGMVjlDsOjxX gF5ep8GtGTGMPJinc64UW9ttY+gxcvnO6nw9zlEBZGNX43tZRa6QVvNRQ8yMNw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gpx8H0YP4z19bZ for ; Mon, 29 Jun 2026 19:25:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21fbf by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 29 Jun 2026 19:25:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 0466e9319858 - stable/15 - MAC/do: parse_and_set_conf(): Obey empty parameters; Add doc List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 0466e931985816eca3f01ad34b7359c3634aadb0 Auto-Submitted: auto-generated Date: Mon, 29 Jun 2026 19:25:51 +0000 Message-Id: <6a42c6bf.21fbf.8e1cdb4@gitrepo.freebsd.org> The branch stable/15 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=0466e931985816eca3f01ad34b7359c3634aadb0 commit 0466e931985816eca3f01ad34b7359c3634aadb0 Author: Olivier Certner AuthorDate: 2026-04-27 16:12:08 +0000 Commit: Olivier Certner CommitDate: 2026-06-29 19:23:47 +0000 MAC/do: parse_and_set_conf(): Obey empty parameters; Add doc parse_and_set_conf() is meant to be used in all situations when there is a need to set or modify some jail's MAC/do configuration. This entails passing the information of whether some parameter was explicitly specified. For example, an administrator setting/modifying jail parameters may not specify executable paths but only rules, in which case the executable paths value is copied from the currently-applicable configuration. The sysctl(8) knobs case always leverages this feature, since setting a knob changes one parameter at a time. Currently, a NULL or empty string argument is treated as a non-specified parameter. This causes a bug where disabling MAC/do in a jail does not actually work because, to this end, parse_and_set_conf() is passed an empty string which it then interprets as a request to copy the currently applicable configuration's value, which may well not be empty. Fix this problem by only treating NULL as a marker for a non-specified parameter, in accordance with the original design for this function. While here, write some documentation to explain the interface. While here, remove the original herald comment for parse_and_set_rules(), which was inadvertently pushed apart from the replacing parse_and_set_conf(). Reviewed by: bapt Fixes: 9818224174c4 ("MAC/do: Executable paths feature (GSoC 2025's final state)") MFC after: 1 month Sponsored by: The FreeBSD Foundation Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/38 (cherry picked from commit d254322f6fa46010bb94d658ff13c06ad438ee77) --- sys/security/mac_do/mac_do.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c index 7b9c45eb265b..cd34d8711487 100644 --- a/sys/security/mac_do/mac_do.c +++ b/sys/security/mac_do/mac_do.c @@ -1363,12 +1363,6 @@ set_default_conf(struct prison *const pr) drop_conf(conf); } -/* - * Parse a rules specification and assign them to a jail. - * - * Returns the same error code as parse_rules() (which see). - */ - static void clone_rules(struct rules *const dst, const struct rules *const src) { @@ -1415,7 +1409,17 @@ clone_exec_paths(struct exec_paths *const dst, sizeof(dst->exec_paths_str)); } -/* Must be called with '*parse_error' set to NULL. */ +/* + * Sets/modifies the MAC/do configuration for a jail. + * + * Must be called with '*parse_error' set to NULL. + * + * Supports explicitly setting all parameters or only some of them, in which + * case the implicit ones are copied from the currently applicable configuration + * (that of the closest ancestor jail that has one). + * + * An unspecified parameter must be passed as NULL. + */ static int parse_and_set_conf(struct prison *pr, const char *rules_string, const char *exec_paths_string, struct parse_error **parse_error) @@ -1423,17 +1427,13 @@ parse_and_set_conf(struct prison *pr, const char *rules_string, struct conf *applicable_conf = NULL; struct conf *conf; int error = 0; - bool need_applicable_conf; - - need_applicable_conf = (rules_string == NULL || rules_string[0] == '\0' || - exec_paths_string == NULL || exec_paths_string[0] == '\0'); - if (need_applicable_conf) + if (rules_string == NULL || exec_paths_string == NULL) applicable_conf = find_conf(pr, NULL); conf = new_conf(); - if (rules_string != NULL && rules_string[0] != '\0') { + if (rules_string != NULL) { error = parse_rules(rules_string, &conf->rules, parse_error); if (error != 0) goto error; @@ -1441,7 +1441,7 @@ parse_and_set_conf(struct prison *pr, const char *rules_string, else if (applicable_conf != NULL) clone_rules(&conf->rules, &applicable_conf->rules); - if (exec_paths_string != NULL && exec_paths_string[0] != '\0') { + if (exec_paths_string != NULL) { error = parse_exec_paths(exec_paths_string, &conf->exec_paths, parse_error); if (error != 0)