0b15456
From 78a9e00a3a9885298f09079c026bf5415c137cca Mon Sep 17 00:00:00 2001
0b15456
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
0b15456
Date: Thu, 20 May 2010 16:19:17 +0200
0b15456
Subject: [PATCH] check the length of the parameters line
0b15456
0b15456
The value of the parameters variable in zipl.conf that is passed as to the kernel
0b15456
into /proc/cmdline is silently truncated to 896 bytes (it matches the value of
0b15456
BOOT_PARM_LENGTH from boot/menu.S). Thus we add a check into zipl and end with
0b15456
an error if the line is longer.
0b15456
---
0b15456
 zipl/include/zipl.h |    3 +++
0b15456
 zipl/src/job.c      |    8 ++++++++
0b15456
 2 files changed, 11 insertions(+), 0 deletions(-)
0b15456
0b15456
diff --git a/zipl/include/zipl.h b/zipl/include/zipl.h
0b15456
index d2d26dd..5e02f13 100644
0b15456
--- a/zipl/include/zipl.h
0b15456
+++ b/zipl/include/zipl.h
0b15456
@@ -40,6 +40,9 @@
0b15456
 
0b15456
 #define MAX_DUMP_VOLUMES		32
0b15456
 
0b15456
+/* defined in boot/menu.S as MENU_PARM_LENGTH */
0b15456
+#define PARMLINE_LENGTH			896
0b15456
+
0b15456
 /* Internal component load address type */
0b15456
 typedef uint64_t address_t;
0b15456
 
0b15456
diff --git a/zipl/src/job.c b/zipl/src/job.c
0b15456
index a65e8c1..76ed5df 100644
0b15456
--- a/zipl/src/job.c
0b15456
+++ b/zipl/src/job.c
0b15456
@@ -894,6 +894,14 @@ get_parmline(char* filename, char* line, char** parmline, address_t* address,
0b15456
 			return -1;
0b15456
 
0b15456
 	} else result = NULL;
0b15456
+	/* check the maximum possible length */
0b15456
+	if (result) {
0b15456
+		len = strlen(result);
0b15456
+		if (len > PARMLINE_LENGTH) {
0b15456
+			error_text("The length of parameters line (%d bytes) exceeds the allowed maximum (%d bytes)", len, PARMLINE_LENGTH);
0b15456
+			return -1;
0b15456
+		}
0b15456
+	}
0b15456
 	*parmline = result;
0b15456
 	*address = addr;
0b15456
 	return 0;
0b15456
-- 
0b15456
1.6.6.1
0b15456