Skip to content

Commit

Permalink
kern_environment: Fix SYSINIT ordering
Browse files Browse the repository at this point in the history
The dynamic environment was being initialized at SI_SUB_KMEM, SI_ORDER_ANY.
I added the hint-merging at SI_SUB_KMEM, SI_ORDER_ANY as well in r335998 -
this can only work by coincidence.

Re-do both to operate at SI_SUB_KMEM + 1, SI_ORDER_FIRST and SI_ORDER_SECOND
respectively to be safe. It's sufficiently obfuscated away as to when in
SU_SUB_KMEM malloc will be available, and the dynamic environment cannot be
relied upon there anyways since it's initialized at SI_ORDER_ANY.

Reported by:	bde
Discussed with:	bde
X-MFC-With: r335998
  • Loading branch information
kevans91 committed Jul 6, 2018
1 parent 9f70292 commit 5a73059
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sys/kern/kern_environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ init_dynamic_kenv(void *data __unused)
mtx_init(&kenv_lock, "kernel environment", NULL, MTX_DEF);
dynamic_kenv = 1;
}
SYSINIT(kenv, SI_SUB_KMEM, SI_ORDER_ANY, init_dynamic_kenv, NULL);
SYSINIT(kenv, SI_SUB_KMEM + 1, SI_ORDER_FIRST, init_dynamic_kenv, NULL);

void
freeenv(char *env)
Expand Down
2 changes: 1 addition & 1 deletion sys/kern/subr_hints.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static_hints_to_env(void *data __unused)
}

/* Any time after dynamic env is setup */
SYSINIT(hintenv, SI_SUB_KMEM, SI_ORDER_ANY, static_hints_to_env, NULL);
SYSINIT(hintenv, SI_SUB_KMEM + 1, SI_ORDER_SECOND, static_hints_to_env, NULL);

/*
* Checks the environment to see if we even have any hints. If it has no hints,
Expand Down

0 comments on commit 5a73059

Please sign in to comment.