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