Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-07-14 11:33:41 +0200
committerJiri Slaby <jslaby@suse.cz>2019-07-14 11:33:52 +0200
commitaaff17cc4be4a9be8ae570f39c3afe1445630078 (patch)
tree7dcab9c2259cdf7e03ca88ba7dd399afe9615a59
parent847c10fe2541133bb7a9982cd11365e95494850d (diff)
lkdtm: support llvm-objcopy (bnc#1012628).
-rw-r--r--patches.kernel.org/5.2.1-040-lkdtm-support-llvm-objcopy.patch65
-rw-r--r--series.conf1
2 files changed, 66 insertions, 0 deletions
diff --git a/patches.kernel.org/5.2.1-040-lkdtm-support-llvm-objcopy.patch b/patches.kernel.org/5.2.1-040-lkdtm-support-llvm-objcopy.patch
new file mode 100644
index 0000000000..fc3a7d3fa8
--- /dev/null
+++ b/patches.kernel.org/5.2.1-040-lkdtm-support-llvm-objcopy.patch
@@ -0,0 +1,65 @@
+From: Nick Desaulniers <ndesaulniers@google.com>
+Date: Wed, 15 May 2019 11:24:41 -0700
+Subject: [PATCH] lkdtm: support llvm-objcopy
+References: bnc#1012628
+Patch-mainline: 5.2.1
+Git-commit: e9e08a07385e08f1a7f85c5d1e345c21c9564963
+
+commit e9e08a07385e08f1a7f85c5d1e345c21c9564963 upstream.
+
+With CONFIG_LKDTM=y and make OBJCOPY=llvm-objcopy, llvm-objcopy errors:
+llvm-objcopy: error: --set-section-flags=.text conflicts with
+--rename-section=.text=.rodata
+
+Rather than support setting flags then renaming sections vs renaming
+then setting flags, it's simpler to just change both at the same time
+via --rename-section. Adding the load flag is required for GNU objcopy
+to mark .rodata Type as PROGBITS after the rename.
+
+This can be verified with:
+$ readelf -S drivers/misc/lkdtm/rodata_objcopy.o
+...
+Section Headers:
+ [Nr] Name Type Address Offset
+ Size EntSize Flags Link Info Align
+...
+ [ 1] .rodata PROGBITS 0000000000000000 00000040
+ 0000000000000004 0000000000000000 A 0 0 4
+...
+
+Which shows that .text is now renamed .rodata, the alloc flag A is set,
+the type is PROGBITS, and the section is not flagged as writeable W.
+
+Cc: stable@vger.kernel.org
+Link: https://sourceware.org/bugzilla/show_bug.cgi?id=24554
+Link: https://github.com/ClangBuiltLinux/linux/issues/448
+Reported-by: Nathan Chancellor <natechancellor@gmail.com>
+Suggested-by: Alan Modra <amodra@gmail.com>
+Suggested-by: Jordan Rupprect <rupprecht@google.com>
+Suggested-by: Kees Cook <keescook@chromium.org>
+Acked-by: Kees Cook <keescook@chromium.org>
+Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/misc/lkdtm/Makefile | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile
+index 951c984de61a..fb10eafe9bde 100644
+--- a/drivers/misc/lkdtm/Makefile
++++ b/drivers/misc/lkdtm/Makefile
+@@ -15,8 +15,7 @@ KCOV_INSTRUMENT_rodata.o := n
+
+ OBJCOPYFLAGS :=
+ OBJCOPYFLAGS_rodata_objcopy.o := \
+- --set-section-flags .text=alloc,readonly \
+- --rename-section .text=.rodata
++ --rename-section .text=.rodata,alloc,readonly,load
+ targets += rodata.o rodata_objcopy.o
+ $(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE
+ $(call if_changed,objcopy)
+--
+2.22.0
+
diff --git a/series.conf b/series.conf
index 02d2dc41a1..29f747d13d 100644
--- a/series.conf
+++ b/series.conf
@@ -66,6 +66,7 @@
patches.kernel.org/5.2.1-037-staging-comedi-amplc_pci230-fix-null-pointer-de.patch
patches.kernel.org/5.2.1-038-staging-mt7621-pci-fix-PCIE_FTS_NUM_LO-macro.patch
patches.kernel.org/5.2.1-039-HID-Add-another-Primax-PIXART-OEM-mouse-quirk.patch
+ patches.kernel.org/5.2.1-040-lkdtm-support-llvm-objcopy.patch
########################################################
# Build fixes that apply to the vanilla kernel too.