kern_environment: Give the static environment a chance to disable MD env

This variable has been given the name "loader_env.disabled" as it's the
primary way most people will have an MD environment. This restores the
previously-default behavior of ignoring the loader(8) environment, which may
be useful for vendor distributions or other scenarios where inheriting the
loader environment may be considered a security issue or potentially
breaking of a more locked-down environment.

As the change to config(5) indicates, disabling the loader environment
should not be a choice made lightly since it may provide ACPI hints and
other useful things that the system can rely on to boot.

An UPDATING entry has been added to mention an upgrade path for those that
may have relied on the previous behavior.

Discussed with:	bde
Relnotes:	yes (maybe)
This commit is contained in:
Kyle Evans 2018-07-12 02:51:50 +00:00
parent ac268038eb
commit 44314c3509
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336217
3 changed files with 37 additions and 9 deletions

View file

@ -31,6 +31,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20180711:
The static environment setup in kernel configs is no longer mutually
exclusive with the loader(8) environment by default. In order to
restore the previous default behavior of disabling the loader(8)
environment if a static environment is present, you must specify
loader_env.disabled=1 in the static environment.
20180705:
The ABI of syscalls used by management tools like sockstat and
netstat has been broken to allow 32-bit binaries to work on

View file

@ -249,11 +249,10 @@ init_static_kenv(char *buf, size_t len)
{
char *eval;
md_envp = buf;
md_env_len = len;
md_env_pos = 0;
/*
* Give the static environment a chance to disable the loader(8)
* environment first. This is done with loader_env.disabled=1.
*
* static_env and static_hints may both be disabled, but in slightly
* different ways. For static_env, we just don't setup kern_envp and
* it's as if a static env wasn't even provided. For static_hints,
@ -263,10 +262,21 @@ init_static_kenv(char *buf, size_t len)
* We're intentionally setting this up so that static_hints.disabled may
* be specified in either the MD env or the static env. This keeps us
* consistent in our new world view.
*
* As a warning, the static environment may not be disabled in any way
* if the static environment has disabled the loader environment.
*/
eval = kern_getenv("static_env.disabled");
if (eval == NULL || strcmp(eval, "1") != 0)
kern_envp = static_env;
kern_envp = static_env;
eval = kern_getenv("loader_env.disabled");
if (eval == NULL || strcmp(eval, "1") != 0) {
md_envp = buf;
md_env_len = len;
md_env_pos = 0;
eval = kern_getenv("static_env.disabled");
if (eval != NULL && strcmp(eval, "1") == 0)
*kern_envp = '\0';
}
eval = kern_getenv("static_hints.disabled");
if (eval != NULL && strcmp(eval, "1") == 0)
*static_hints = '\0';

View file

@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 26, 2018
.Dd July 11, 2018
.Dt CONFIG 5
.Os
.Sh NAME
@ -125,13 +125,24 @@ environment will take precedence over environment variables specified in
and environment variables specified in the dynamic environment take precedence
over both of these.
.Pp
.Va loader_env.disabled=1
may be specified in the static environment to disable the
.Xr loader 8
environment.
Disabling the
.Xr loader 8
should be done with caution and due consideration for whether or not it supplies
environment variables needed for properly booting the system.
.Pp
.Va static_env.disabled=1
may be specified in the
.Xr loader 8
environment to disable use of this compiled-in environment.
environment to disable use of the static environment.
This option has no effect if specified in any environment after the
.Xr loader 8
environment is processed.
This option is not usable in conjunction with
.Va loader_env.disabled .
.Pp
This directive is useful for setting kernel tunables in
embedded environments that do not start from