git: 2870493f1f55 - main - kboot: Properly cap number of segments loaded for kexec
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 15 Jul 2022 18:04:07 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=2870493f1f55d5c00e5593f336dc05805863db7f commit 2870493f1f55d5c00e5593f336dc05805863db7f Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-06-29 22:31:23 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-07-15 18:00:51 +0000 kboot: Properly cap number of segments loaded for kexec Linux has an arbitrary limit of 16 segments. Make sure we don't load too many. Sponsored by: Netflix --- stand/kboot/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stand/kboot/main.c b/stand/kboot/main.c index 79c03398ba6d..83ad0ceb8a18 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -340,15 +340,17 @@ time(time_t *tloc) return (rv); } -struct host_kexec_segment loaded_segments[128]; +struct host_kexec_segment loaded_segments[HOST_KEXEC_SEGMENT_MAX]; int nkexec_segments = 0; static ssize_t get_phys_buffer(vm_offset_t dest, const size_t len, void **buf) { int i = 0; - const size_t segsize = 4*1024*1024; + const size_t segsize = 8*1024*1024; + if (nkexec_segments == HOST_KEXEC_SEGMENT_MAX) + panic("Tried to load too many kexec segments"); for (i = 0; i < nkexec_segments; i++) { if (dest >= (vm_offset_t)loaded_segments[i].mem && dest < (vm_offset_t)loaded_segments[i].mem +