From b5c2ed5e02cfe862eded56be7f6c1106e84e6e6c Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Wed, 30 Jan 2008 19:10:45 -0500 Subject: Kexec command line length Fine, New patch attached. This patch does 5 things: 1) moves command line out of the zero page (struct bootparam) 2) extends command line length to support 2K command lines 3) adds a check to ensure that command line length is reasonably sized for new boot protocols 4) adds a check to ensure that command line length is reasonably sized for old boot protocols 5) imports variables from latest struct setup_header in kernel bootparams.h Incorporates simplified version checking for boot protocol and conservatively warns if the kernels boot protocol is below version 2.06 which is guaranteed to have 2K commandlines (even though some arches may have that support in older boot protocols) Neil Signed-off-by: Neil Horman include/x86/x86-linux.h | 20 ++++++++++++++------ kexec/arch/i386/kexec-bzImage.c | 11 +++++++++++ kexec/arch/i386/x86-linux-setup.c | 3 ++- 3 files changed, 27 insertions(+), 7 deletions(-) Signed-off-by: Simon Horman --- kexec/arch/i386/kexec-bzImage.c | 11 +++++++++++ kexec/arch/i386/x86-linux-setup.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'kexec/arch') diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c index 8fde799..93e37a4 100644 --- a/kexec/arch/i386/kexec-bzImage.c +++ b/kexec/arch/i386/kexec-bzImage.c @@ -134,6 +134,17 @@ int do_bzImage_load(struct kexec_info *info, return -1; } + if (setup_header.protocol_version >= 0x0206) { + if (command_line_len > setup_header.cmdline_size) { + dbgprintf("Kernel command line too long for kernel!\n"); + return -1; + } + } else { + if (command_line_len > 255) { + dbgprintf("WARNING: This kernel may only support 255 byte command lines\n"); + } + } + if (setup_header.protocol_version >= 0x0205) { relocatable_kernel = setup_header.relocatable_kernel; dbgprintf("bzImage is relocatable\n"); diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c index df2f5c0..68234fa 100644 --- a/kexec/arch/i386/x86-linux-setup.c +++ b/kexec/arch/i386/x86-linux-setup.c @@ -38,8 +38,9 @@ void init_linux_parameters(struct x86_linux_param_header *real_mode) /* Boot block magic */ memcpy(real_mode->header_magic, "HdrS", 4); - real_mode->protocol_version = 0x0203; + real_mode->protocol_version = 0x0206; real_mode->initrd_addr_max = DEFAULT_INITRD_ADDR_MAX; + real_mode->cmdline_size = COMMAND_LINE_SIZE; } void setup_linux_bootloader_parameters( -- cgit