git: kernel: Skip oversized loader environment entries
Aaron LI
aly at crater.dragonflybsd.org
Wed Nov 18 05:12:57 PST 2026
commit 64ff7438753ad35fd8e9938a6fb44bece0df1418
Author: David Bidner <david at crap.solutions>
Date: Tue Nov 10 06:39:35 2026 +0100
kernel: Skip oversized loader environment entries
kenv_init() copies every loader environment string into the dynamic
kenv without a length limit, and kgetenv() later copies the value
into a 258-byte stack buffer with strcpy(). A long value overflows
the buffer when it is read, for example by an unprivileged kenv(1)
call, and causes a fatal trap.
Skip entries longer than KENV_MNAMELEN + KENV_MVALLEN + 2 bytes and
print a warning, like FreeBSD's init_dynamic_kenv() does. An entry
(name, '=' and value) of up to 257 characters keeps working.
Bug: https://bugs.dragonflybsd.org/issues/3466
Summary of changes:
sys/kern/kern_environment.c | 6 ++++++
1 file changed, 6 insertions(+)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/64ff7438753ad35fd8e9938a6fb44bece0df1418
--
DragonFly BSD source repository
More information about the Commits
mailing list