Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Nov 2018 19:04:51 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r340647 - stable/12/sys/kern
Message-ID:  <201811191904.wAJJ4p2j015217@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Nov 19 19:04:50 2018
New Revision: 340647
URL: https://svnweb.freebsd.org/changeset/base/340647

Log:
  MFC r340392: Add dynamic_kenv assertion to init_static_kenv
  
  Both to formally document the requirement that this not be called after the
  dynamic kenv is setup, and to perhaps help static analyzers figure out
  what's going on. While calling init_static_kenv this late isn't fatal, there
  are some caveats that the caller should be aware of:
  
  - Late calls are effectively a no-op, as far as default FreeBSD is
  concerned, as everything will switch to searching the dynamic kenv once it's
  available.
  
  - Each of the kern_getenv calls will leak memory, as it's assumed that
  these are searching static environment and allocations will not be made.
  
  As such, this usage is not sensible and should be detected.

Modified:
  stable/12/sys/kern/kern_environment.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_environment.c
==============================================================================
--- stable/12/sys/kern/kern_environment.c	Mon Nov 19 18:59:06 2018	(r340646)
+++ stable/12/sys/kern/kern_environment.c	Mon Nov 19 19:04:50 2018	(r340647)
@@ -249,6 +249,7 @@ init_static_kenv(char *buf, size_t len)
 {
 	char *eval;
 
+	KASSERT(!dynamic_kenv, ("kenv: dynamic_kenv already initialized"));
 	/*
 	 * Give the static environment a chance to disable the loader(8)
 	 * environment first.  This is done with loader_env.disabled=1.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811191904.wAJJ4p2j015217>