]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0130-objtool-Move-kernel-headers-code-sync-check-to-a-scr.patch
add objtool build fix
[pve-kernel.git] / patches / kernel / 0130-objtool-Move-kernel-headers-code-sync-check-to-a-scr.patch
CommitLineData
321d628a
FG
1From b6ebe31d563b5fade20c8516eaff92ab3122f1b8 Mon Sep 17 00:00:00 2001
2From: Josh Poimboeuf <jpoimboe@redhat.com>
3Date: Mon, 6 Nov 2017 07:21:51 -0600
b378f209 4Subject: [PATCH 130/233] objtool: Move kernel headers/code sync check to a
321d628a
FG
5 script
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10CVE-2017-5754
11
12Replace the nasty diff checks in the objtool Makefile with a clean bash
13script, and make the warnings more specific.
14
15Heavily inspired by tools/perf/check-headers.sh.
16
17Suggested-by: Ingo Molnar <mingo@kernel.org>
18Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
19Cc: Linus Torvalds <torvalds@linux-foundation.org>
20Cc: Peter Zijlstra <peterz@infradead.org>
21Cc: Thomas Gleixner <tglx@linutronix.de>
22Link: http://lkml.kernel.org/r/ab015f15ccd8c0c6008493c3c6ee3d495eaf2927.1509974346.git.jpoimboe@redhat.com
23Signed-off-by: Ingo Molnar <mingo@kernel.org>
24(cherry picked from commit a89ec413c623eb2870180bcad678046bf7bc8465)
25Signed-off-by: Andy Whitcroft <apw@canonical.com>
26Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
27(cherry picked from commit 4e72ce95a057e744b8d580239e2d8afa51118d82)
28Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
29---
30 tools/objtool/Makefile | 16 +---------------
31 tools/objtool/sync-check.sh | 29 +++++++++++++++++++++++++++++
32 2 files changed, 30 insertions(+), 15 deletions(-)
33 create mode 100755 tools/objtool/sync-check.sh
34
35diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
36index f95f48e445c3..90b0241f3ccc 100644
37--- a/tools/objtool/Makefile
38+++ b/tools/objtool/Makefile
39@@ -41,22 +41,8 @@ include $(srctree)/tools/build/Makefile.include
40 $(OBJTOOL_IN): fixdep FORCE
41 @$(MAKE) $(build)=objtool
42
43-# Busybox's diff doesn't have -I, avoid warning in that case
44-#
45 $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
46- @(diff -I 2>&1 | grep -q 'option requires an argument' && \
47- test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \
48- diff arch/x86/lib/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
49- diff arch/x86/lib/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
50- diff arch/x86/lib/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
51- diff arch/x86/tools/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
52- diff arch/x86/include/asm/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
53- diff arch/x86/include/asm/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
54- diff arch/x86/include/asm/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
55- || echo "warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true
56- @(test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \
57- diff ../../arch/x86/include/asm/orc_types.h arch/x86/include/asm/orc_types.h >/dev/null) \
58- || echo "warning: objtool: orc_types.h differs from kernel" >&2 )) || true
59+ @./sync-check.sh
60 $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@
61
62
63diff --git a/tools/objtool/sync-check.sh b/tools/objtool/sync-check.sh
64new file mode 100755
65index 000000000000..1470e74e9d66
66--- /dev/null
67+++ b/tools/objtool/sync-check.sh
68@@ -0,0 +1,29 @@
69+#!/bin/sh
70+# SPDX-License-Identifier: GPL-2.0
71+
72+FILES='
73+arch/x86/lib/insn.c
74+arch/x86/lib/inat.c
75+arch/x86/lib/x86-opcode-map.txt
76+arch/x86/tools/gen-insn-attr-x86.awk
77+arch/x86/include/asm/insn.h
78+arch/x86/include/asm/inat.h
79+arch/x86/include/asm/inat_types.h
80+arch/x86/include/asm/orc_types.h
81+'
82+
83+check()
84+{
85+ local file=$1
86+
87+ diff $file ../../$file > /dev/null ||
88+ echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'"
89+}
90+
91+if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then
92+ exit 0
93+fi
94+
95+for i in $FILES; do
96+ check $i
97+done
98--
992.14.2
100