]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0133-objtool-Fix-64-bit-build-on-32-bit-host.patch
revert buggy SCSI error handler commit
[pve-kernel.git] / patches / kernel / 0133-objtool-Fix-64-bit-build-on-32-bit-host.patch
1 From 475d437587dd1de2d6a53f7fbbb9bc88c7700fc3 Mon Sep 17 00:00:00 2001
2 From: Mikulas Patocka <mpatocka@redhat.com>
3 Date: Sat, 2 Dec 2017 16:17:44 -0600
4 Subject: [PATCH 133/242] objtool: Fix 64-bit build on 32-bit host
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 CVE-2017-5754
10
11 The new ORC unwinder breaks the build of a 64-bit kernel on a 32-bit
12 host. Building the kernel on a i386 or x32 host fails with:
13
14 orc_dump.c: In function 'orc_dump':
15 orc_dump.c:105:26: error: passing argument 2 of 'elf_getshdrnum' from incompatible pointer type [-Werror=incompatible-pointer-types]
16 if (elf_getshdrnum(elf, &nr_sections)) {
17 ^
18 In file included from /usr/local/include/gelf.h:32:0,
19 from elf.h:22,
20 from warn.h:26,
21 from orc_dump.c:20:
22 /usr/local/include/libelf.h:304:12: note: expected 'size_t * {aka unsigned int *}' but argument is of type 'long unsigned int *'
23 extern int elf_getshdrnum (Elf *__elf, size_t *__dst);
24 ^~~~~~~~~~~~~~
25 orc_dump.c:190:17: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'Elf64_Sxword {aka long long int}' [-Werror=format=]
26 printf("%s+%lx:", name, rela.r_addend);
27 ~~^ ~~~~~~~~~~~~~
28 %llx
29
30 Fix the build failure.
31
32 Another problem is that if the user specifies HOSTCC or HOSTLD
33 variables, they are ignored in the objtool makefile. Change the
34 Makefile to respect these variables.
35
36 Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
37 Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
38 Cc: Linus Torvalds <torvalds@linux-foundation.org>
39 Cc: Peter Zijlstra <peterz@infradead.org>
40 Cc: Sven Joachim <svenjoac@gmx.de>
41 Cc: Thomas Gleixner <tglx@linutronix.de>
42 Fixes: 627fce14809b ("objtool: Add ORC unwind table generation")
43 Link: http://lkml.kernel.org/r/19f0e64d8e07e30a7b307cd010eb780c404fe08d.1512252895.git.jpoimboe@redhat.com
44 Signed-off-by: Ingo Molnar <mingo@kernel.org>
45 (cherry picked from commit 0db897fb081b66c26a338e5481f317c71df779c9)
46 Signed-off-by: Andy Whitcroft <apw@canonical.com>
47 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
48 (cherry picked from commit 979c9a5cacd1d40d08c1c24ed5c5810cf7f3069c)
49 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
50 ---
51 tools/objtool/Makefile | 8 +++++---
52 tools/objtool/orc_dump.c | 7 ++++---
53 2 files changed, 9 insertions(+), 6 deletions(-)
54
55 diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
56 index 847e99aa54ea..5c71bae01064 100644
57 --- a/tools/objtool/Makefile
58 +++ b/tools/objtool/Makefile
59 @@ -6,9 +6,11 @@ ARCH := x86
60 endif
61
62 # always use the host compiler
63 -CC = gcc
64 -LD = ld
65 -AR = ar
66 +HOSTCC ?= gcc
67 +HOSTLD ?= ld
68 +CC = $(HOSTCC)
69 +LD = $(HOSTLD)
70 +AR = ar
71
72 ifeq ($(srctree),)
73 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
74 diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c
75 index 36c5bf6a2675..c3343820916a 100644
76 --- a/tools/objtool/orc_dump.c
77 +++ b/tools/objtool/orc_dump.c
78 @@ -76,7 +76,8 @@ int orc_dump(const char *_objname)
79 int fd, nr_entries, i, *orc_ip = NULL, orc_size = 0;
80 struct orc_entry *orc = NULL;
81 char *name;
82 - unsigned long nr_sections, orc_ip_addr = 0;
83 + size_t nr_sections;
84 + Elf64_Addr orc_ip_addr = 0;
85 size_t shstrtab_idx;
86 Elf *elf;
87 Elf_Scn *scn;
88 @@ -187,10 +188,10 @@ int orc_dump(const char *_objname)
89 return -1;
90 }
91
92 - printf("%s+%lx:", name, rela.r_addend);
93 + printf("%s+%llx:", name, (unsigned long long)rela.r_addend);
94
95 } else {
96 - printf("%lx:", orc_ip_addr + (i * sizeof(int)) + orc_ip[i]);
97 + printf("%llx:", (unsigned long long)(orc_ip_addr + (i * sizeof(int)) + orc_ip[i]));
98 }
99
100
101 --
102 2.14.2
103