From: Greg Kroah-Hartman Date: Tue, 13 Aug 2019 06:09:54 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v5.2.9~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffa4206265d4a2a4456ed07329a3b0fac5c2b350;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: lkdtm-support-llvm-objcopy.patch --- diff --git a/queue-4.14/lkdtm-support-llvm-objcopy.patch b/queue-4.14/lkdtm-support-llvm-objcopy.patch new file mode 100644 index 00000000000..728555e0cb0 --- /dev/null +++ b/queue-4.14/lkdtm-support-llvm-objcopy.patch @@ -0,0 +1,97 @@ +From e9e08a07385e08f1a7f85c5d1e345c21c9564963 Mon Sep 17 00:00:00 2001 +From: Nick Desaulniers +Date: Wed, 15 May 2019 11:24:41 -0700 +Subject: lkdtm: support llvm-objcopy + +From: Nick Desaulniers + +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 +Suggested-by: Alan Modra +Suggested-by: Jordan Rupprect +Suggested-by: Kees Cook +Acked-by: Kees Cook +Reviewed-by: Nathan Chancellor +Signed-off-by: Nick Desaulniers +Signed-off-by: Greg Kroah-Hartman + +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 +Suggested-by: Alan Modra +Suggested-by: Jordan Rupprect +Suggested-by: Kees Cook +Acked-by: Kees Cook +Reviewed-by: Nathan Chancellor +Signed-off-by: Nick Desaulniers +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/misc/Makefile | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/misc/Makefile ++++ b/drivers/misc/Makefile +@@ -69,8 +69,7 @@ KCOV_INSTRUMENT_lkdtm_rodata.o := n + + OBJCOPYFLAGS := + OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \ +- --set-section-flags .text=alloc,readonly \ +- --rename-section .text=.rodata ++ --rename-section .text=.rodata,alloc,readonly,load + targets += lkdtm_rodata.o lkdtm_rodata_objcopy.o + $(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o FORCE + $(call if_changed,objcopy) diff --git a/queue-4.14/series b/queue-4.14/series index 318f70b27f7..843d1e48ac0 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -8,3 +8,4 @@ mmc-cavium-set-the-correct-dma-max-segment-size-for-mmc_host.patch mmc-cavium-add-the-missing-dma-unmap-when-the-dma-has-finished.patch loop-set-pf_memalloc_noio-for-the-worker-thread.patch input-synaptics-enable-rmi-mode-for-hp-spectre-x360.patch +lkdtm-support-llvm-objcopy.patch