* [PATCH v2] lkdtm: support llvm-objcopy [not found] <CAKwvOdk_KmyT4yZOz8iczxeP7mYq-h5LmjzkE5yhsodupRLxEQ@mail.gmail.com> @ 2019-05-15 18:12 ` Nick Desaulniers 2019-05-15 18:19 ` Nathan Chancellor 0 siblings, 1 reply; 5+ messages in thread From: Nick Desaulniers @ 2019-05-15 18:12 UTC (permalink / raw) To: gregkh Cc: clang-built-linux, Nick Desaulniers, stable, Nathan Chancellor, Alan Modra, Jordan Rupprect, Kees Cook, Arnd Bergmann, linux-kernel 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 <nathanchance@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> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> --- Changes from v1 -> v2: * add load flag, as per Kees and Alan. * update commit message to mention reason for load flag. * add Kees' and Alan's suggested by. * carry Kees' Ack. * cc stable. 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.21.0.1020.gf2820cf01a-goog ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] lkdtm: support llvm-objcopy 2019-05-15 18:12 ` [PATCH v2] lkdtm: support llvm-objcopy Nick Desaulniers @ 2019-05-15 18:19 ` Nathan Chancellor 2019-05-15 18:24 ` [PATCH v3] " Nick Desaulniers 0 siblings, 1 reply; 5+ messages in thread From: Nathan Chancellor @ 2019-05-15 18:19 UTC (permalink / raw) To: Nick Desaulniers Cc: gregkh, clang-built-linux, stable, Nathan Chancellor, Alan Modra, Jordan Rupprect, Kees Cook, Arnd Bergmann, linux-kernel On Wed, May 15, 2019 at 11:12:04AM -0700, 'Nick Desaulniers' via Clang Built Linux wrote: > 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 <nathanchance@gmail.com> Doesn't look like this got updated. I don't want to make you send a v3 just for that though since it's purely cosmetic and adding my tag below will ensure I get copied on any backports and such. > 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> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> > --- > Changes from v1 -> v2: > * add load flag, as per Kees and Alan. > * update commit message to mention reason for load flag. > * add Kees' and Alan's suggested by. > * carry Kees' Ack. > * cc stable. > > 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.21.0.1020.gf2820cf01a-goog > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] lkdtm: support llvm-objcopy 2019-05-15 18:19 ` Nathan Chancellor @ 2019-05-15 18:24 ` Nick Desaulniers [not found] ` <20190517001002.D1A262084A@mail.kernel.org> 0 siblings, 1 reply; 5+ messages in thread From: Nick Desaulniers @ 2019-05-15 18:24 UTC (permalink / raw) To: gregkh Cc: clang-built-linux, Nick Desaulniers, stable, Nathan Chancellor, Alan Modra, Jordan Rupprect, Kees Cook, Arnd Bergmann, linux-kernel 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> --- Changes from v2 -> v3: * correct Nathan's email address and collect his reviewed by. Changes from v1 -> v2: * add load flag, as per Kees and Alan. * update commit message to mention reason for load flag. * add Kees' and Alan's suggested by. * carry Kees' Ack. * cc stable. 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.21.0.1020.gf2820cf01a-goog ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <20190517001002.D1A262084A@mail.kernel.org>]
* Re: [PATCH v3] lkdtm: support llvm-objcopy [not found] ` <20190517001002.D1A262084A@mail.kernel.org> @ 2019-05-17 4:06 ` Nathan Chancellor 2019-05-17 4:09 ` Nathan Chancellor 0 siblings, 1 reply; 5+ messages in thread From: Nathan Chancellor @ 2019-05-17 4:06 UTC (permalink / raw) To: Sasha Levin; +Cc: Nick Desaulniers, gregkh, clang-built-linux, stable On Fri, May 17, 2019 at 12:10:02AM +0000, Sasha Levin wrote: > Hi, > > [This is an automated email] > > This commit has been processed because it contains a -stable tag. > The stable tag indicates that it's relevant for the following trees: all Nick, the stable tag should probably specify 4.8+ since the commit it fixes came in during 4.8-rc1. Cc: stable@vger.kernel.org # 4.8+ Might also help to add: Fixes: 9a49a528dcf3 ("lkdtm: add function for testing .rodata section") > > The bot has tested the following trees: v5.1.2, v5.0.16, v4.19.43, v4.14.119, v4.9.176, v4.4.179, v3.18.140. > > v5.1.2: Build OK! > v5.0.16: Build OK! > v4.19.43: Build OK! > v4.14.119: Failed to apply! Possible dependencies: > 039a1c42058d ("lkdtm: Relocate code to subdirectory") However, it will still need a manual backport because of the lack of this commit. I've attached the current patch backported for reference, the git am flags '-3 -p4 --directory=drivers/misc' help get it proper then the conflict is rather easy to resolve. Thanks, Nathan ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] lkdtm: support llvm-objcopy 2019-05-17 4:06 ` Nathan Chancellor @ 2019-05-17 4:09 ` Nathan Chancellor 0 siblings, 0 replies; 5+ messages in thread From: Nathan Chancellor @ 2019-05-17 4:09 UTC (permalink / raw) To: Sasha Levin; +Cc: Nick Desaulniers, gregkh, clang-built-linux, stable [-- Attachment #1: Type: text/plain, Size: 1223 bytes --] On Thu, May 16, 2019 at 09:06:13PM -0700, Nathan Chancellor wrote: > On Fri, May 17, 2019 at 12:10:02AM +0000, Sasha Levin wrote: > > Hi, > > > > [This is an automated email] > > > > This commit has been processed because it contains a -stable tag. > > The stable tag indicates that it's relevant for the following trees: all > > Nick, the stable tag should probably specify 4.8+ since the commit it > fixes came in during 4.8-rc1. > > Cc: stable@vger.kernel.org # 4.8+ > > Might also help to add: > > Fixes: 9a49a528dcf3 ("lkdtm: add function for testing .rodata section") > > > > > The bot has tested the following trees: v5.1.2, v5.0.16, v4.19.43, v4.14.119, v4.9.176, v4.4.179, v3.18.140. > > > > v5.1.2: Build OK! > > v5.0.16: Build OK! > > v4.19.43: Build OK! > > v4.14.119: Failed to apply! Possible dependencies: > > 039a1c42058d ("lkdtm: Relocate code to subdirectory") > > However, it will still need a manual backport because of the lack of > this commit. I've attached the current patch backported for reference, Would help if I actually did this... :^) > the git am flags '-3 -p4 --directory=drivers/misc' help get it proper > then the conflict is rather easy to resolve. > > Thanks, > Nathan [-- Attachment #2: 0001-lkdtm-support-llvm-objcopy.patch --] [-- Type: text/plain, Size: 2363 bytes --] From 10c0a74a8d92669b91b66efe6b72550fc24e8e7d Mon Sep 17 00:00:00 2001 From: Nick Desaulniers <ndesaulniers@google.com> Date: Wed, 15 May 2019 11:24:41 -0700 Subject: [PATCH] lkdtm: support llvm-objcopy 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: Nathan Chancellor <natechancellor@gmail.com> --- drivers/misc/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index c3c8624f4d95..805835c2b99b 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -70,8 +70,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) -- 2.22.0.rc0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-17 4:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAKwvOdk_KmyT4yZOz8iczxeP7mYq-h5LmjzkE5yhsodupRLxEQ@mail.gmail.com>
2019-05-15 18:12 ` [PATCH v2] lkdtm: support llvm-objcopy Nick Desaulniers
2019-05-15 18:19 ` Nathan Chancellor
2019-05-15 18:24 ` [PATCH v3] " Nick Desaulniers
[not found] ` <20190517001002.D1A262084A@mail.kernel.org>
2019-05-17 4:06 ` Nathan Chancellor
2019-05-17 4:09 ` Nathan Chancellor
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).