linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lkdtm: Fix targets for objcopy usage
@ 2016-07-29  2:30 Kees Cook
  2016-07-29  9:37 ` Mark Rutland
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2016-07-29  2:30 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Arnd Bergmann, Mark Rutland, Greg Kroah-Hartman, linux-kernel

The targets for lkdtm's objcopy were missing which caused them to always
be rebuilt. This corrects the problem.

Additionally, commit f8fa70f392fa ("arm64: localise Image objcopy flags")
has landed now, so this removes the work-around for the global OBJCOPY
flag setting.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/misc/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 4387ccb79e64..132f4e3462ba 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -65,9 +65,9 @@ lkdtm-$(CONFIG_LKDTM)		+= lkdtm_perms.o
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_rodata_objcopy.o
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_usercopy.o
 
-OBJCOPYFLAGS :=
 OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
 			--set-section-flags .text=alloc,readonly \
 			--rename-section .text=.rodata
-$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o
+targets += lkdtm_rodata.o lkdtm_rodata_objcopy.o
+$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o FORCE
 	$(call if_changed,objcopy)
-- 
2.7.4


-- 
Kees Cook
Brillo & Chrome OS Security

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] lkdtm: Fix targets for objcopy usage
  2016-07-29  2:30 [PATCH] lkdtm: Fix targets for objcopy usage Kees Cook
@ 2016-07-29  9:37 ` Mark Rutland
  2016-08-01 21:25   ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Rutland @ 2016-07-29  9:37 UTC (permalink / raw)
  To: Kees Cook; +Cc: Linus Torvalds, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

Hi,

On Thu, Jul 28, 2016 at 07:30:39PM -0700, Kees Cook wrote:
> The targets for lkdtm's objcopy were missing which caused them to always
> be rebuilt. This corrects the problem.
> 
> Additionally, commit f8fa70f392fa ("arm64: localise Image objcopy flags")
> has landed now, so this removes the work-around for the global OBJCOPY
> flag setting.
> 
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Kees Cook <keescook@chromium.org>

With this applied, LKDTM builds fine for me on arm64, the redundant
rebuilds are gone, and the result appears to work. So FWIW:

Tested-by: Mark Rutland <mark.rutland@arm.com>

Thanks,
Mark.

> ---
>  drivers/misc/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 4387ccb79e64..132f4e3462ba 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -65,9 +65,9 @@ lkdtm-$(CONFIG_LKDTM)		+= lkdtm_perms.o
>  lkdtm-$(CONFIG_LKDTM)		+= lkdtm_rodata_objcopy.o
>  lkdtm-$(CONFIG_LKDTM)		+= lkdtm_usercopy.o
>  
> -OBJCOPYFLAGS :=
>  OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
>  			--set-section-flags .text=alloc,readonly \
>  			--rename-section .text=.rodata
> -$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o
> +targets += lkdtm_rodata.o lkdtm_rodata_objcopy.o
> +$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o FORCE
>  	$(call if_changed,objcopy)
> -- 
> 2.7.4
> 
> 
> -- 
> Kees Cook
> Brillo & Chrome OS Security
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lkdtm: Fix targets for objcopy usage
  2016-07-29  9:37 ` Mark Rutland
@ 2016-08-01 21:25   ` Kees Cook
  2016-08-02  9:50     ` Mark Rutland
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2016-08-01 21:25 UTC (permalink / raw)
  To: Mark Rutland; +Cc: Linus Torvalds, Arnd Bergmann, Greg Kroah-Hartman, LKML

On Fri, Jul 29, 2016 at 2:37 AM, Mark Rutland <mark.rutland@arm.com> wrote:
> Hi,
>
> On Thu, Jul 28, 2016 at 07:30:39PM -0700, Kees Cook wrote:
>> The targets for lkdtm's objcopy were missing which caused them to always
>> be rebuilt. This corrects the problem.
>>
>> Additionally, commit f8fa70f392fa ("arm64: localise Image objcopy flags")
>> has landed now, so this removes the work-around for the global OBJCOPY
>> flag setting.
>>
>> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
> With this applied, LKDTM builds fine for me on arm64, the redundant
> rebuilds are gone, and the result appears to work. So FWIW:
>
> Tested-by: Mark Rutland <mark.rutland@arm.com>

Argh, it looks like ARM suffers the same global OBJCOPY problem, so
I'm going to leave that change out. :(

-Kees

>
> Thanks,
> Mark.
>
>> ---
>>  drivers/misc/Makefile | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
>> index 4387ccb79e64..132f4e3462ba 100644
>> --- a/drivers/misc/Makefile
>> +++ b/drivers/misc/Makefile
>> @@ -65,9 +65,9 @@ lkdtm-$(CONFIG_LKDTM)               += lkdtm_perms.o
>>  lkdtm-$(CONFIG_LKDTM)                += lkdtm_rodata_objcopy.o
>>  lkdtm-$(CONFIG_LKDTM)                += lkdtm_usercopy.o
>>
>> -OBJCOPYFLAGS :=
>>  OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
>>                       --set-section-flags .text=alloc,readonly \
>>                       --rename-section .text=.rodata
>> -$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o
>> +targets += lkdtm_rodata.o lkdtm_rodata_objcopy.o
>> +$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o FORCE
>>       $(call if_changed,objcopy)
>> --
>> 2.7.4
>>
>>
>> --
>> Kees Cook
>> Brillo & Chrome OS Security
>>



-- 
Kees Cook
Chrome OS & Brillo Security

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lkdtm: Fix targets for objcopy usage
  2016-08-01 21:25   ` Kees Cook
@ 2016-08-02  9:50     ` Mark Rutland
  2016-08-02 15:18       ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Rutland @ 2016-08-02  9:50 UTC (permalink / raw)
  To: Kees Cook; +Cc: Linus Torvalds, Arnd Bergmann, Greg Kroah-Hartman, LKML

On Mon, Aug 01, 2016 at 02:25:48PM -0700, Kees Cook wrote:
> On Fri, Jul 29, 2016 at 2:37 AM, Mark Rutland <mark.rutland@arm.com> wrote:
> > Hi,
> >
> > On Thu, Jul 28, 2016 at 07:30:39PM -0700, Kees Cook wrote:
> >> The targets for lkdtm's objcopy were missing which caused them to always
> >> be rebuilt. This corrects the problem.
> >>
> >> Additionally, commit f8fa70f392fa ("arm64: localise Image objcopy flags")
> >> has landed now, so this removes the work-around for the global OBJCOPY
> >> flag setting.
> >>
> >> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> >> Signed-off-by: Kees Cook <keescook@chromium.org>
> >
> > With this applied, LKDTM builds fine for me on arm64, the redundant
> > rebuilds are gone, and the result appears to work. So FWIW:
> >
> > Tested-by: Mark Rutland <mark.rutland@arm.com>
> 
> Argh, it looks like ARM suffers the same global OBJCOPY problem, so
> I'm going to leave that change out. :(

:(

FWIW, I dropped a patch for ARM [1] in Russell's patch system [2]. Hopefully
that will be picked up during the v4.9 merge window.

Looking again, it appears a number of other arches might be affected:

[mark@leverpostej:~/src/linux]% git grep 'OBJCOPYFLAGS\s\+:=' -- arch/*/Makefile
arch/arm/Makefile:OBJCOPYFLAGS  :=-O binary -R .comment -S
arch/blackfin/Makefile:OBJCOPYFLAGS     := -O binary -R .note -R .comment -S
arch/cris/Makefile:OBJCOPYFLAGS := -O binary -R .note -R .comment -S
arch/ia64/Makefile:OBJCOPYFLAGS := --strip-all
arch/m32r/Makefile:OBJCOPYFLAGS := -O binary -R .note -R .comment -S
arch/metag/Makefile:OBJCOPYFLAGS                                := -O binary -R .note -R .comment -S
arch/mn10300/Makefile:OBJCOPYFLAGS      := -O binary -R .note -R .comment -R .GCC-command-line -R .note.gnu.build-id -S
arch/openrisc/Makefile:OBJCOPYFLAGS    := -O binary -R .note -R .comment -S
arch/s390/Makefile:OBJCOPYFLAGS := -O binary
arch/sh/Makefile:OBJCOPYFLAGS   := -O binary -R .note -R .note.gnu.build-id -R .comment \
arch/unicore32/Makefile:OBJCOPYFLAGS            := -O binary -R .note -R .note.gnu.build-id -R .comment -S

... so we probably need to fix up these first, regardless.

In the mean time, can we add the targets dependency, but leave the flags
work-around intact? 

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-July/442974.html
[2] http://www.armlinux.org.uk/developer/patches/viewpatch.php?id=8588/1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lkdtm: Fix targets for objcopy usage
  2016-08-02  9:50     ` Mark Rutland
@ 2016-08-02 15:18       ` Kees Cook
  0 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2016-08-02 15:18 UTC (permalink / raw)
  To: Mark Rutland; +Cc: Linus Torvalds, Arnd Bergmann, Greg Kroah-Hartman, LKML

On Tue, Aug 2, 2016 at 2:50 AM, Mark Rutland <mark.rutland@arm.com> wrote:
> On Mon, Aug 01, 2016 at 02:25:48PM -0700, Kees Cook wrote:
>> On Fri, Jul 29, 2016 at 2:37 AM, Mark Rutland <mark.rutland@arm.com> wrote:
>> > Hi,
>> >
>> > On Thu, Jul 28, 2016 at 07:30:39PM -0700, Kees Cook wrote:
>> >> The targets for lkdtm's objcopy were missing which caused them to always
>> >> be rebuilt. This corrects the problem.
>> >>
>> >> Additionally, commit f8fa70f392fa ("arm64: localise Image objcopy flags")
>> >> has landed now, so this removes the work-around for the global OBJCOPY
>> >> flag setting.
>> >>
>> >> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
>> >> Signed-off-by: Kees Cook <keescook@chromium.org>
>> >
>> > With this applied, LKDTM builds fine for me on arm64, the redundant
>> > rebuilds are gone, and the result appears to work. So FWIW:
>> >
>> > Tested-by: Mark Rutland <mark.rutland@arm.com>
>>
>> Argh, it looks like ARM suffers the same global OBJCOPY problem, so
>> I'm going to leave that change out. :(
>
> :(
>
> FWIW, I dropped a patch for ARM [1] in Russell's patch system [2]. Hopefully
> that will be picked up during the v4.9 merge window.
>
> Looking again, it appears a number of other arches might be affected:
>
> [mark@leverpostej:~/src/linux]% git grep 'OBJCOPYFLAGS\s\+:=' -- arch/*/Makefile
> arch/arm/Makefile:OBJCOPYFLAGS  :=-O binary -R .comment -S
> arch/blackfin/Makefile:OBJCOPYFLAGS     := -O binary -R .note -R .comment -S
> arch/cris/Makefile:OBJCOPYFLAGS := -O binary -R .note -R .comment -S
> arch/ia64/Makefile:OBJCOPYFLAGS := --strip-all
> arch/m32r/Makefile:OBJCOPYFLAGS := -O binary -R .note -R .comment -S
> arch/metag/Makefile:OBJCOPYFLAGS                                := -O binary -R .note -R .comment -S
> arch/mn10300/Makefile:OBJCOPYFLAGS      := -O binary -R .note -R .comment -R .GCC-command-line -R .note.gnu.build-id -S
> arch/openrisc/Makefile:OBJCOPYFLAGS    := -O binary -R .note -R .comment -S
> arch/s390/Makefile:OBJCOPYFLAGS := -O binary
> arch/sh/Makefile:OBJCOPYFLAGS   := -O binary -R .note -R .note.gnu.build-id -R .comment \
> arch/unicore32/Makefile:OBJCOPYFLAGS            := -O binary -R .note -R .note.gnu.build-id -R .comment -S
>
> ... so we probably need to fix up these first, regardless.

Oof, yeah. I'll add this to the "weird little things to fix" TODO list. :)

>
> In the mean time, can we add the targets dependency, but leave the flags
> work-around intact?

Yeah, done. I've sent a pull request to Greg for that now.

-Kees

>
> Thanks,
> Mark.
>
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-July/442974.html
> [2] http://www.armlinux.org.uk/developer/patches/viewpatch.php?id=8588/1



-- 
Kees Cook
Chrome OS & Brillo Security

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-02 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-29  2:30 [PATCH] lkdtm: Fix targets for objcopy usage Kees Cook
2016-07-29  9:37 ` Mark Rutland
2016-08-01 21:25   ` Kees Cook
2016-08-02  9:50     ` Mark Rutland
2016-08-02 15:18       ` Kees Cook

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).