Accepting request 220793 from devel:ARM:Factory

- add 0001-kexec-fs2dt-fix-endianess-conversion.patch:
  * fix ppc64 and arm
- refresh device-tree-buffer-overflows.patch with the version
  that went upstream

OBS-URL: https://build.opensuse.org/request/show/220793
OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=35
This commit is contained in:
Tony Jones 2014-02-04 15:57:09 +00:00 committed by Git OBS Bridge
parent 5ab38458ae
commit 213612d58b
4 changed files with 118 additions and 7 deletions

View File

@ -0,0 +1,78 @@
From 1cbddc80ddfe34cdcdac11c0562e4d8395c48b16 Mon Sep 17 00:00:00 2001
From: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Date: Tue, 15 Oct 2013 19:05:28 +0200
Subject: [PATCH] kexec/fs2dt: fix endianess conversion
Patch-mainline: yes
While reviewing fs2dt.c in the common kexec directory, in order to use it to
support little endian ppc64 architecture, I found some endianess
conversion's issues.
In dt_reserve, dt_base is a pointer and thus should not be converted.
In checkprop, values read from the device tree are big endian encoded and
should be converted if CPU is running in little endian mode.
In add_dyn_reconf_usable_mem_property__, fix extraneous endianess conversion
of rlen which should be natively used to increase the dt pointer.
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/fs2dt.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index 242a15e..5d774ae 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -84,7 +84,7 @@ static void dt_reserve(unsigned **dt_ptr, unsigned words)
offset = *dt_ptr - dt_base;
dt_base = new_dt;
dt_cur_size = new_size;
- *dt_ptr = cpu_to_be32((unsigned)dt_base + offset);
+ *dt_ptr = dt_base + offset;
memset(*dt_ptr, 0, (new_size - offset)*4);
}
}
@@ -112,19 +112,22 @@ static void checkprop(char *name, unsigned *data, int len)
if ((data == NULL) && (base || size || end))
die("unrecoverable error: no property data");
else if (!strcmp(name, "linux,rtas-base"))
- base = *data;
+ base = be32_to_cpu(*data);
else if (!strcmp(name, "linux,tce-base"))
- base = *(unsigned long long *) data;
+ base = be64_to_cpu(*(unsigned long long *) data);
else if (!strcmp(name, "rtas-size") ||
!strcmp(name, "linux,tce-size"))
- size = *data;
+ size = be32_to_cpu(*data);
else if (reuse_initrd && !strcmp(name, "linux,initrd-start"))
if (len == 8)
- base = *(unsigned long long *) data;
+ base = be64_to_cpu(*(unsigned long long *) data);
else
- base = *data;
+ base = be32_to_cpu(*data);
else if (reuse_initrd && !strcmp(name, "linux,initrd-end"))
- end = *(unsigned long long *) data;
+ if (len == 8)
+ end = be64_to_cpu(*(unsigned long long *) data);
+ else
+ end = be32_to_cpu(*data);
if (size && end)
die("unrecoverable error: size and end set at same time\n");
@@ -267,7 +270,7 @@ static void add_dyn_reconf_usable_mem_property__(int fd)
pad_structure_block(rlen);
memcpy(dt, ranges, rlen);
free(ranges);
- dt += cpu_to_be32((rlen + 3)/4);
+ dt += (rlen + 3)/4;
}
static void add_dyn_reconf_usable_mem_property(struct dirent *dp, int fd)
--
1.8.4.1

View File

@ -1,16 +1,39 @@
References: http://lists.infradead.org/pipermail/kexec/2014-February/011009.html
From 01d6e4371f2c49459f3600a2bbadbc66a94f870b Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dmueller@suse.com>
Date: Mon, 3 Feb 2014 18:50:04 +0100
Subject: [PATCH] Avoid buffer overflow on strncat usage
Signed-off-by: Dirk Mueller <dmueller at suse.com>
--- kexec/fs2dt.c
strncat() does not want the total size but the maximum length
(without trailing NUL) that can still be added. Switch over
to snprintf which is both more readable and avoids this issue.
Signed-off-by: Dirk Mueller <dmueller@suse.com>
---
kexec/fs2dt.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Index: kexec/fs2dt.c
===================================================================
--- kexec/fs2dt.c.orig
+++ kexec/fs2dt.c
@@ -639,8 +639,8 @@
@@ -614,8 +614,7 @@ static void putnode(void)
* code can print 'I'm in purgatory' message. Currently only
* pseries/hvcterminal is supported.
*/
- strcpy(filename, pathname);
- strncat(filename, "linux,stdout-path", MAXPATH);
+ snprintf(filename, MAXPATH, "%slinux,stdout-path", pathname);
fd = open(filename, O_RDONLY);
if (fd == -1) {
printf("Unable to find %s, printing from purgatory is diabled\n",
@@ -638,9 +637,7 @@ static void putnode(void)
}
read(fd, buff, statbuf.st_size);
close(fd);
strncpy(filename, "/proc/device-tree/", MAXPATH);
- strncpy(filename, "/proc/device-tree/", MAXPATH);
- strncat(filename, buff, MAXPATH);
- strncat(filename, "/compatible", MAXPATH);
+ strncat(filename, buff, MAXPATH-strlen(filename)-1);
+ strncat(filename, "/compatible", MAXPATH-strlen(filename)-1);
+ snprintf(filename, MAXPATH, "/proc/device-tree/%s/compatible", buff);
fd = open(filename, O_RDONLY);
if (fd == -1) {
printf("Unable to find %s printing from purgatory is diabled\n",

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Feb 4 13:00:37 UTC 2014 - dmueller@suse.com
- add 0001-kexec-fs2dt-fix-endianess-conversion.patch:
* fix ppc64 and arm
- refresh device-tree-buffer-overflows.patch with the version
that went upstream
-------------------------------------------------------------------
Mon Feb 3 14:17:09 UTC 2014 - dmueller@suse.com

View File

@ -38,6 +38,7 @@ Patch2: %{name}-xen-balloon-up.patch
Patch3: %{name}-disable-test.patch
Patch4: kexec-aarch64.patch
Patch5: device-tree-buffer-overflows.patch
Patch6: 0001-kexec-fs2dt-fix-endianess-conversion.patch
Url: ftp://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
#!BuildIgnore: fop
@ -65,6 +66,7 @@ the loaded kernel after it panics.
%patch3 -p1
%patch4 -p1
%patch5
%patch6 -p1
%build
# disable as-needed