From nobody Fri May 29 16:01:44 2026 X-Original-To: dev-commits-src-main@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 4gRp5501pxz6flXS for ; Fri, 29 May 2026 16:01:45 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gRp543Dxtz3HSd for ; Fri, 29 May 2026 16:01:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780070504; 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=kfkahbPsEfE/xnqQowDJ9iXbFoMf8DhA5G6qr3r5yZU=; b=AMn4hvCqUkU5pOr/S1AIWw/JBIuYMyhpP7W1hNcAVeqnE0zJ0deIossmJ2avxVsY33nSrv wsVdy0XMCq1Xvg5/NzIKKgwYFMim09BrHHGt4ZxR1BlKyq6+OKm7HBwN/8A7wDbPYQNn4q AkzgjTE7t+o7wIvbKkdrcvSGGT/b/Jxi4JlLtlnzYCGMRbICV2YGem6PKjZDGDK5oBSCSN laO+kOQMe3boNQXNnnycNRyiKGK1z/6HNbh8maEsQAV74gEH7YD2lyEJqdb7dU95zE3KdV Mrnt3rv9vx3sPtk55HuxLdOI3muW+4gxlu7pZpU9M3b4+meFUv7bGyWGZXBfcw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780070504; a=rsa-sha256; cv=none; b=hRyPiz3wMlgOliy04n3NJMnyBW3c68NEHDjnRdH0fImfE5l7YglOXikbRKMcQ0s72G7/a+ EkpCKekGyy0FlW1YLNGGcOEIOYQuYTPEgIByZaWLgEZXE2QeKzTOUz9dASEFn3JdWwvC5N ncHWjqS80Sb1XbJqwBVm1RutxRnYbrPFBgHED/bVu4TdhDsiFoQL5zPZjijNety83dENMi c+xUxrRrZcfTFuaawZyGkt7fBswbasR5TcphOzxTXU4vbeE+nbmNsv95hkzFZ/06AXc+6P WqiTHeTpn/p3vrkT0k47F5DadJaQis4CevxElh0aE5yfMBUwfri4uC7SnGdJAQ== 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=1780070504; 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=kfkahbPsEfE/xnqQowDJ9iXbFoMf8DhA5G6qr3r5yZU=; b=JfAKvDCisYPAFJdTntOdznGpH+fOD1TkNwT0njTuucuj+u7Rm69UqnHLVtd5PAkDN2KNW+ BPiYH/qP8dw14kW4O4UUDzRY2ACVof5xC9u3QIqfb2wkOZnDCMyrq0o5/0ixQZrj1areyj NQNrBJj7odng62jv4ZESP6rvIckW10K6hsddvGxZ++WgwfoV5IBflF+5KXo+ZntN8CUisu yZAAUelcCrzY1XtyshpOr4RNbm0O51pCbvY0+fiE97LYjPVsCxFZ4dwaa8PK0QVhOhRMvI IiP3Bi4YW9Zk1Ml/mKdZg7bMttC9yoTNbQuSYiacT9zbDMx2fU4GvTkwP19QZg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gRp542pLJzgCL for ; Fri, 29 May 2026 16:01:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 342b9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 29 May 2026 16:01:44 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: d254322f6fa4 - main - MAC/do: parse_and_set_conf(): Obey empty parameters; Add doc List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: d254322f6fa46010bb94d658ff13c06ad438ee77 Auto-Submitted: auto-generated Date: Fri, 29 May 2026 16:01:44 +0000 Message-Id: <6a19b868.342b9.21db378@gitrepo.freebsd.org> The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=d254322f6fa46010bb94d658ff13c06ad438ee77 commit d254322f6fa46010bb94d658ff13c06ad438ee77 Author: Olivier Certner AuthorDate: 2026-04-27 16:12:08 +0000 Commit: Olivier Certner CommitDate: 2026-05-29 15:23:10 +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 --- 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 b24daaf093c0..3ae5aba4bb8a 100644 --- a/sys/security/mac_do/mac_do.c +++ b/sys/security/mac_do/mac_do.c @@ -1361,12 +1361,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) { @@ -1413,7 +1407,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) @@ -1421,17 +1425,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; @@ -1439,7 +1439,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)