0130-objtool-Move-kernel-headers-code-sync-check-to-a-scr.patch 3.7 KB

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