linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kexec ppc64: fix misaligned cmdline
@ 2007-06-04  7:23 Michael Neuling
  2007-06-04  9:22 ` Milton Miller
  2007-06-04 23:49 ` David Gibson
  0 siblings, 2 replies; 10+ messages in thread
From: Michael Neuling @ 2007-06-04  7:23 UTC (permalink / raw)
  To: horms; +Cc: kexec, miltonm, linuxppc-dev

If the cmdline changes between boots, we can get misalignment of the
bootargs entry, which in turn corrupts our device tree blob and hence
kills our kexec boot.  

Specifically, if the cmdline length was >= 8 before and the new cmdline
length is < 8, we can get corruption.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 kexec/arch/ppc64/fs2dt.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: kexec-tools-testing/kexec/arch/ppc64/fs2dt.c
===================================================================
--- kexec-tools-testing.orig/kexec/arch/ppc64/fs2dt.c
+++ kexec-tools-testing/kexec/arch/ppc64/fs2dt.c
@@ -197,6 +197,7 @@ static void putprops(char *fn, struct di
 	struct dirent *dp;
 	int i = 0, fd, len;
 	struct stat statbuf;
+	int dt_realigned = 0;
 
 	for (i = 0; i < numlist; i++) {
 		dp = nlist[i];
@@ -243,8 +244,10 @@ static void putprops(char *fn, struct di
 		*dt++ = len;
 		*dt++ = propnum(fn);
 
-		if ((len >= 8) && ((unsigned long)dt & 0x4))
+		if ((len >= 8) && ((unsigned long)dt & 0x4)){
 			dt++;
+			dt_realigned = 1;
+		}
 
 		fd = open(pathname, O_RDONLY);
 		if (fd == -1)
@@ -283,6 +286,8 @@ static void putprops(char *fn, struct di
 			strcat(local_cmdline, " ");
 			cmd_len = strlen(local_cmdline);
 			cmd_len = cmd_len + 1;
+			if (dt_realigned && cmd_len < 8)
+				dt--;
 			memcpy(dt, local_cmdline,cmd_len);
 			len = cmd_len;
 			*dt_len = cmd_len;

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-06-19  5:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-04  7:23 [PATCH] kexec ppc64: fix misaligned cmdline Michael Neuling
2007-06-04  9:22 ` Milton Miller
2007-06-04  9:42   ` Michael Neuling
2007-06-07  1:19     ` Michael Neuling
2007-06-07 16:19       ` Geoff Levand
2007-06-19  5:06       ` Horms
2007-06-04 23:49 ` David Gibson
2007-06-04 23:56   ` Michael Neuling
2007-06-05  0:16     ` David Gibson
2007-06-05  0:58       ` Michael Neuling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).