MAC/do: Fix recently-introduced comments
Reviewed by: bapt
Fixes: 9818224174 ("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
This commit is contained in:
@@ -344,7 +344,7 @@ toast_rules(struct rules *const rules)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Assuming storage is zeroed already */
|
/* Assumes storage has been zeroed. */
|
||||||
static void
|
static void
|
||||||
init_rules(struct rules *const rules)
|
init_rules(struct rules *const rules)
|
||||||
{
|
{
|
||||||
@@ -1148,12 +1148,13 @@ parse_exec_paths(const char *const string, struct exec_paths *const exec_paths,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find conf applicable to the passed prison.
|
* Find configuration applicable to the passed prison.
|
||||||
*
|
*
|
||||||
* Returns the applicable conf (and never NULL). 'pr' must be unlocked.
|
* Returns the applicable configuration (and never NULL). 'pr' must be
|
||||||
* 'aprp' is set to the (ancestor) prison holding these, and it must be unlocked
|
* unlocked. 'aprp' is set to the (ancestor) prison holding these, and it must
|
||||||
* once the caller is done accessing the conf. '*aprp' is equal to 'pr' if and
|
* be unlocked once the caller is done accessing the configuration. '*aprp' is
|
||||||
* only if the current jail has its own set of conf.
|
* equal to 'pr' if and only if the current jail has its own specific
|
||||||
|
* configuration.
|
||||||
*/
|
*/
|
||||||
static struct conf *
|
static struct conf *
|
||||||
find_conf(struct prison *const pr, struct prison **const aprp)
|
find_conf(struct prison *const pr, struct prison **const aprp)
|
||||||
@@ -1272,6 +1273,9 @@ remove_conf(struct prison *const pr)
|
|||||||
drop_conf(old_conf);
|
drop_conf(old_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assign an already-built configuration to a jail.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
set_conf(struct prison *const pr, struct conf *const conf)
|
set_conf(struct prison *const pr, struct conf *const conf)
|
||||||
{
|
{
|
||||||
@@ -1290,7 +1294,7 @@ set_conf(struct prison *const pr, struct conf *const conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assigns default conf to a jail.
|
* Assigns the default configuration to a jail.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
set_default_conf(struct prison *const pr)
|
set_default_conf(struct prison *const pr)
|
||||||
@@ -1553,9 +1557,12 @@ mac_do_jail_check(void *obj, void *data)
|
|||||||
int error, jsys, rules_len = 0, exec_paths_len = 0;
|
int error, jsys, rules_len = 0, exec_paths_len = 0;
|
||||||
bool has_rules, has_exec_paths;
|
bool has_rules, has_exec_paths;
|
||||||
|
|
||||||
/* Mark unspecified */
|
|
||||||
error = vfs_copyopt(opts, "mac.do", &jsys, sizeof(jsys));
|
error = vfs_copyopt(opts, "mac.do", &jsys, sizeof(jsys));
|
||||||
if (error == ENOENT)
|
if (error == ENOENT)
|
||||||
|
/*
|
||||||
|
* Mark unspecified. Will fill it up below depending on the
|
||||||
|
* other options.
|
||||||
|
*/
|
||||||
jsys = -1;
|
jsys = -1;
|
||||||
else {
|
else {
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
@@ -1566,12 +1573,13 @@ mac_do_jail_check(void *obj, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use vfs_getopt() here instead of vfs_getopts() to get the length.
|
* We use vfs_getopt() below instead of vfs_getopts() to get the length.
|
||||||
* We perform the additional checks done by the latter here, even if
|
* We perform the additional checks done by the latter here, even if
|
||||||
* jail_set() calls vfs_getopts() itself later (they becoming
|
* jail_set() calls vfs_getopts() itself later (they becoming
|
||||||
* inconsistent wouldn't cause any security problem).
|
* inconsistent wouldn't cause any security problem).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Rules. */
|
||||||
error = vfs_getopt(opts, "mac.do.rules", (void **)&rules_string,
|
error = vfs_getopt(opts, "mac.do.rules", (void **)&rules_string,
|
||||||
&rules_len);
|
&rules_len);
|
||||||
if (error == ENOENT)
|
if (error == ENOENT)
|
||||||
@@ -1590,7 +1598,7 @@ mac_do_jail_check(void *obj, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle 'exec_paths' input */
|
/* Executable paths. */
|
||||||
error = vfs_getopt(opts, "mac.do.exec_paths",
|
error = vfs_getopt(opts, "mac.do.exec_paths",
|
||||||
(void **)&exec_paths_string, &exec_paths_len);
|
(void **)&exec_paths_string, &exec_paths_len);
|
||||||
if (error == ENOENT)
|
if (error == ENOENT)
|
||||||
@@ -1611,7 +1619,7 @@ mac_do_jail_check(void *obj, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Be liberal, considering that an empty rule or exec paths
|
* Be liberal, considering that an empty rule or execution paths
|
||||||
* specification is equivalent to no specification. This affects the
|
* specification is equivalent to no specification. This affects the
|
||||||
* JAIL_SYS_DISABLE and JAIL_SYS_INHERIT sanity checks below.
|
* JAIL_SYS_DISABLE and JAIL_SYS_INHERIT sanity checks below.
|
||||||
*/
|
*/
|
||||||
@@ -1619,15 +1627,19 @@ mac_do_jail_check(void *obj, void *data)
|
|||||||
has_exec_paths = exec_paths_string != NULL &&
|
has_exec_paths = exec_paths_string != NULL &&
|
||||||
exec_paths_string[0] != '\0';
|
exec_paths_string[0] != '\0';
|
||||||
|
|
||||||
/* Infer 'jsys' if needed */
|
/* If not specified, infer 'jsys' from passed options. */
|
||||||
if (jsys == -1) {
|
if (jsys == -1) {
|
||||||
|
/*
|
||||||
|
* Default in absence of "mac.do.rules" and "mac.do.exec_paths"
|
||||||
|
* is to disable (and, in particular, not inherit).
|
||||||
|
*/
|
||||||
if (has_rules || has_exec_paths)
|
if (has_rules || has_exec_paths)
|
||||||
jsys = JAIL_SYS_NEW;
|
jsys = JAIL_SYS_NEW;
|
||||||
else
|
else
|
||||||
jsys = JAIL_SYS_DISABLE;
|
jsys = JAIL_SYS_DISABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Final checks based on resolved 'jsys' */
|
/* Final checks based on resolved 'jsys'. */
|
||||||
switch (jsys) {
|
switch (jsys) {
|
||||||
case JAIL_SYS_DISABLE:
|
case JAIL_SYS_DISABLE:
|
||||||
case JAIL_SYS_INHERIT:
|
case JAIL_SYS_INHERIT:
|
||||||
@@ -1651,7 +1663,6 @@ mac_do_jail_check(void *obj, void *data)
|
|||||||
"rules nor executable paths specified");
|
"rules nor executable paths specified");
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
/* Allow: rules only, exec_paths only (though exec_paths only is discouraged), or both */
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user