freebsd-src/stand
Kyle Evans 3da568710f stand: module: unlink the entire tail when dependencies fail to load
Assume you have loader configured to load linux64, which has a
dependency on both linux_common and mqueuefs but neither the kernel
nor kernel config in question have the mqueuefs module included.

When the load command for linux64 fails to find mqueuefs, it will
free both linux64 and linux_common as they were loaded first, but only
linux64 gets removed from the module list.  As a result, future
traversals hit an easy use-after-free with linux_common.

Fix it so that we unlink the entire tail of the list.  Anything after
the initially loaded module is, by definition, a dependency on the
loaded module while we're still in the load command, so we can just
discard the entire tail.  If linux_common were loaded before linux64, it
should not move to a position during this load where it would suddenly
be missing from the view presented to the kernel.

Reported by:	philip
Reviewed by:	imp, philip, tsoome
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45731
2024-06-25 15:32:08 -05:00
..
arm64 stand: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
common stand: module: unlink the entire tail when dependencies fail to load 2024-06-25 15:32:08 -05:00
defaults stand/lua: always allow overriding with local config files 2024-02-02 12:04:57 -07:00
efi boot/efi: Fix warning for non-standard formats when debugging 2024-06-14 11:11:05 -06:00
fdt libsa: Remove redundant sys/cdefs.h 2024-02-22 09:31:57 -07:00
ficl stand: Remove dangling mips references 2024-02-28 07:09:41 -07:00
ficl32 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
fonts Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
forth loader.4th dictthreshold too small 2024-03-18 16:16:29 -07:00
i386 textvidc: Reindent 2024-05-19 22:05:43 -06:00
images Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
kboot stand/kboot: Fix the linker script OUTPUT_FORMAT 2024-05-22 08:17:52 +00:00
kshim Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
liblua stand: Spell LUA_COMPILE_SET correctly. 2024-05-11 12:09:51 -06:00
liblua32 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libofw loader: fix stupid typos 2024-05-19 23:04:18 -06:00
libsa loader/zfs: Fix to actually return the last error 2024-02-29 09:12:21 -07:00
libsa32 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
lua loader/lua: Remove workaround for command_error 2024-02-29 10:58:59 -07:00
man loader.efi.8: Fix a typo 2023-11-22 13:25:34 +01:00
powerpc boot1.chrp: Include memset 2024-06-14 09:34:05 -06:00
uboot loader: fix stupid typos 2024-05-19 23:04:18 -06:00
usb Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
userboot userboot: Use C99 Initializers for each of the consoles here 2024-05-19 22:05:42 -06:00
defs.mk kboot: Add our own lua bindings 2024-02-15 20:59:23 -07:00
fdt.mk stand: Rename LIBFDT to LIBSAFDT 2023-11-07 09:57:32 -05:00
ficl.mk Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
loader.mk Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
lua.mk Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.amd64 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.inc arm64: Allow userspace to be built with PAC and BTI 2024-05-22 17:02:26 +00:00
veriexec.mk libsecureboot do not report expected unverified files 2024-02-12 14:35:01 -08:00