Re: [Etherboot-developers] [PATCH] Expand kernel command line length limit

Michael Brown <[email protected]> Thu, 12 Jun 2008 02:21:40 +0100 (BST)
Newsgroups gmane.network.etherboot.user,gmane.network.etherboot.devel
Message-ID <[email protected]>
On Wed, 11 Jun 2008, Will Nowak wrote:
> The Linux kernel has a max command line length of 2047 chars now a
> days. gpxe should probably support something similar.

Thanks for picking up on this.  A couple of comments, inline below:

--- a/src/arch/i386/include/bzimage.h
+++ b/src/arch/i386/include/bzimage.h
@@ -124,6 +124,6 @@ struct bzimage_cmdline {
 #define BZI_STACK_SIZE 0x1000
 
 /** Maximum size of command line */
-#define BZI_CMDLINE_SIZE 0x100
+#define BZI_CMDLINE_SIZE 0x800
 
 #endif /* _BZIMAGE_H */


We need to respect the 0x100 byte limit for older kernels.  There is a 
cmdline_size field added in kernel 2.6.22; we should use this field 
instead of just assuming 0x800 bytes.


--- a/src/hci/commands/image_cmd.c
+++ b/src/hci/commands/image_cmd.c
@@ -49,7 +49,7 @@ enum image_action {
  */
 static int imgfill_cmdline ( struct image *image, unsigned int nargs, 
 			     char **args ) {
-	char buf[256];
+	char buf[2048];
 	size_t used = 0;
 
 	memset ( buf, 0, sizeof ( buf ) );

We can't allocate such a large buffer from what is only a 4096-byte stack; 
we should allocate a buffer that is just large enough to hold the 
arguments.


I have pushed two changes (4c85017 and ac28d05) which implement the 
"proper" fixes; could you check to see if these work for you?

Thanks,

Michael

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php