Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 May 2026 16:01:49 +0000
From:      Olivier Certner <olce@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 51cc5840b66c - main - MAC/do: Configuration: Fix default values: Remove jail creation method
Message-ID:  <6a19b86d.338f5.e63f434@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=51cc5840b66c9565e1740c1198a0e684d81e3734

commit 51cc5840b66c9565e1740c1198a0e684d81e3734
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-04-28 13:10:14 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-05-29 15:27:57 +0000

    MAC/do: Configuration: Fix default values: Remove jail creation method
    
    mac_do_jail_create() would create a default configuration on the
    just-created jail, erroneously causing mac_do_jail_set() to then
    retrieve it and use it as a model when determining the default values
    for not-specified parameters, instead of using the configuration
    applicable to the parent jail.
    
    Setting a default configuration in mac_do_jail_create() had been done as
    a kind of defensive measure to prevent a created jail not to have
    a configuration (effectively making it inherit from an ancestor jail,
    which is a security hazard except if explicitly requested).  However,
    this measure was never really effective (osd_jail_call(PR_METHOD_CREATE)
    in kern_jail_set() calls the PR_PETHOD_CREATE methods in an unspecified
    order, and stops at the first error), so we are forced to rely in any
    case on the fact that an error in a PR_METHOD_CREATE or PR_METHOD_SET
    method leads to stopping the jail creation process (which is the case
    today; see kern_jail_set()).
    
    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 | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c
index 7890af9bcfec..fb7eb00cd6d5 100644
--- a/sys/security/mac_do/mac_do.c
+++ b/sys/security/mac_do/mac_do.c
@@ -1548,16 +1548,6 @@ SYSCTL_PROC(_security_mac_do, OID_AUTO, exec_paths,
 SYSCTL_JAIL_PARAM_STRING(_mac_do, exec_paths, CTLFLAG_RW, MAX_EXEC_PATHS_SIZE,
     "Jail MAC/do executable paths");
 
-static int
-mac_do_jail_create(void *obj, void *data)
-{
-	struct prison *const pr = obj;
-
-	set_default_conf(pr);
-
-	return (0);
-}
-
 static int
 mac_do_jail_get(void *obj, void *data)
 {
@@ -1879,12 +1869,14 @@ mac_do_jail_set(void *obj, void *data)
 /*
  * OSD jail methods.
  *
- * There is no PR_METHOD_REMOVE, as OSD storage is destroyed by the common jail
- * code (see prison_cleanup()), which triggers a run of our dealloc_jail_osd()
- * destructor.
+ * There is no PR_METHOD_REMOVE method, as OSD storage is destroyed by the
+ * common jail code (see prison_cleanup()), which triggers a run of our
+ * dealloc_jail_osd() destructor.  There is neither a PR_METHOD_CREATE as
+ * PR_METHOD_SET is called just after (or the created jail destroyed if some
+ * PR_METHOD_CREATE fails), and our mac_do_jail_set() will ensure a jail is
+ * properly configured.
  */
 static const osd_method_t osd_methods[PR_MAXMETHOD] = {
-	[PR_METHOD_CREATE] = mac_do_jail_create,
 	[PR_METHOD_GET] = mac_do_jail_get,
 	[PR_METHOD_CHECK] = mac_do_jail_check,
 	[PR_METHOD_SET] = mac_do_jail_set,


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a19b86d.338f5.e63f434>