All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: Neil Horman <nhorman@redhat.com>,
	horms@verge.net.au, kexec@lists.infradead.org
Subject: Re: Kexec command line length
Date: Wed, 30 Jan 2008 19:10:45 -0500	[thread overview]
Message-ID: <20080131000926.GA15474@localhost.localdomain> (raw)
In-Reply-To: <20080130214551.GC15415@redhat.com>

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 <nhorman@tuxdriver.com>


 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(-)



diff --git a/include/x86/x86-linux.h b/include/x86/x86-linux.h
index afe66bd..4f3507e 100644
--- a/include/x86/x86-linux.h
+++ b/include/x86/x86-linux.h
@@ -144,18 +144,22 @@ struct x86_linux_param_header {
 	/* 2.04+ */
 	uint32_t kernel_alignment;		/* 0x230 */
 	uint8_t  relocatable_kernel;		/* 0x234 */
-	uint8_t  reserved15[0x2d0 - 0x235];	/* 0x230 */
+	uint8_t  reserved15[3];			/* 0x235 */
+	uint32_t cmdline_size;			/* 0x238 */
+	uint32_t hardware_subarch;		/* 0x23C */
+	uint64_t hardware_subarch_data;		/* 0x240 */
+	uint8_t  reserved16[0x2d0 - 0x248];	/* 0x248 */
 #endif
 	struct e820entry e820_map[E820MAX];	/* 0x2d0 */
 						/* 0x550 */
-#define COMMAND_LINE_SIZE 256
+#define COMMAND_LINE_SIZE 2048 
 };
 
 struct x86_linux_faked_param_header {
 	struct x86_linux_param_header hdr;	/* 0x00 */
-	uint8_t reserved16[688];		/* 0x550 */
-	uint8_t command_line[COMMAND_LINE_SIZE]; /* 0x800 */
-	uint8_t reserved17[1792];		/* 0x900 - 0x1000 */
+	uint8_t reserved17[0xab0];		/* 0x550 */
+	uint8_t command_line[COMMAND_LINE_SIZE]; /* 0x1000 */
+	uint8_t reserved18[0x200];		/* 0x1800 - 0x2000 */
 };
 
 struct x86_linux_header {
@@ -206,7 +210,11 @@ struct x86_linux_header {
 #else
 	uint32_t kernel_alignment;		/* 0x230 */
 	uint8_t  relocatable_kernel;		/* 0x234 */
-	uint8_t  tail[32*1024 - 0x235];		/* 0x230 */
+	uint8_t  reserved6[3];			/* 0x235 */
+	uint32_t cmdline_size;                  /* 0x238 */
+	uint32_t hardware_subarch;              /* 0x23C */
+	uint64_t hardware_subarch_data;         /* 0x240 */
+	uint8_t  tail[32*1024 - 0x248];		/* 0x248 */
 #endif
 } PACKED;
 
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(

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2008-01-31  0:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-14 13:43 Kexec command line length Neil Horman
2008-01-14 14:50 ` Bernhard Walle
2008-01-14 15:40   ` Neil Horman
2008-01-15 15:27 ` Vivek Goyal
2008-01-15 17:09   ` Neil Horman
2008-01-15 17:37     ` Vivek Goyal
2008-01-25 12:35       ` Neil Horman
2008-01-25 15:39         ` Vivek Goyal
2008-01-25 15:44           ` H. Peter Anvin
2008-01-25 19:50             ` Neil Horman
2008-01-25 19:54               ` H. Peter Anvin
2008-01-25 20:11                 ` Neil Horman
2008-01-25 20:13               ` Vivek Goyal
2008-01-25 20:54                 ` Neil Horman
2008-01-28 17:08                   ` Neil Horman
2008-01-28 19:37                     ` Vivek Goyal
2008-01-28 20:07                       ` Neil Horman
2008-01-28 20:20                         ` Vivek Goyal
2008-01-28 20:53                           ` Neil Horman
2008-01-28 21:09                             ` Vivek Goyal
2008-01-28 21:29                             ` Bernhard Walle
2008-01-29  1:01                               ` Neil Horman
2008-01-29 15:41                                 ` Vivek Goyal
2008-01-29 18:17                                   ` Bernhard Walle
2008-01-29 18:52                                     ` Neil Horman
2008-01-29 19:57                                     ` Neil Horman
2008-01-30 20:53                                       ` Vivek Goyal
2008-01-30 20:59                                         ` Neil Horman
2008-01-30 21:08                                           ` Vivek Goyal
2008-01-30 21:18                                             ` Neil Horman
2008-01-30 21:45                                               ` Vivek Goyal
2008-01-31  0:10                                                 ` Neil Horman [this message]
2008-01-31  7:16                                                 ` Bernhard Walle
2008-02-12 21:11                                                   ` Neil Horman
2008-02-18  3:14                                                     ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080131000926.GA15474@localhost.localdomain \
    --to=nhorman@tuxdriver.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=nhorman@redhat.com \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.