All of lore.kernel.org
 help / color / mirror / Atom feed
* kexec breaks with 5.4 due to memzero_explicit
@ 2019-10-07  3:09 Arvind Sankar
  2019-10-07  8:50 ` Hans de Goede
  0 siblings, 1 reply; 10+ messages in thread
From: Arvind Sankar @ 2019-10-07  3:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Hans de Goede, Ingo Molnar, x86

Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
according to git bisect.

The patch mentions that it impacts purgatory code, but I don't see any
changes to actually include the definition of memzero_explicit into
purgatory? It used to get memset from arch/x86/boot/compressed/string.c
I think.

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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07  3:09 kexec breaks with 5.4 due to memzero_explicit Arvind Sankar
@ 2019-10-07  8:50 ` Hans de Goede
  2019-10-07  9:10   ` Hans de Goede
  0 siblings, 1 reply; 10+ messages in thread
From: Hans de Goede @ 2019-10-07  8:50 UTC (permalink / raw)
  To: Arvind Sankar, linux-kernel; +Cc: Ingo Molnar, x86

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

Hi,

On 07-10-2019 05:09, Arvind Sankar wrote:
> Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
> memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
> sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
> according to git bisect.

Hmm, it (obviously) does build for me and using kexec still also works
for me.

But it seems that you are right and that this should not build, weird.

Thank you for reporting this. I've attached a patch which should fix this,
I'm also sending this the regular way, so that the x86 maintainers can pick it up.

Can you please give this a try and let us know if it fixes things for you?

Regards,

Hans

[-- Attachment #2: 0001-x86-boot-Provide-memzero_explicit.patch --]
[-- Type: text/x-patch, Size: 1100 bytes --]

From d371dbdef635b57d993bda428a9eb6b929f4472d Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 7 Oct 2019 10:43:00 +0200
Subject: [PATCH] x86/boot: Provide memzero_explicit

The purgatory code now uses the shared lib/crypto/sha256.c sha256
implementation. This needs memzero_explicit, implement this.

Reported-by: Arvind Sankar <nivedita@alum.mit.edu>
Fixes: 906a4bb97f5d ("crypto: sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/x86/boot/compressed/string.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/boot/compressed/string.c b/arch/x86/boot/compressed/string.c
index 81fc1eaa3229..511332e279fe 100644
--- a/arch/x86/boot/compressed/string.c
+++ b/arch/x86/boot/compressed/string.c
@@ -50,6 +50,11 @@ void *memset(void *s, int c, size_t n)
 	return s;
 }
 
+void memzero_explicit(void *s, size_t count)
+{
+	memset(s, 0, count);
+}
+
 void *memmove(void *dest, const void *src, size_t n)
 {
 	unsigned char *d = dest;
-- 
2.23.0


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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07  8:50 ` Hans de Goede
@ 2019-10-07  9:10   ` Hans de Goede
  2019-10-07 13:09     ` Ingo Molnar
  2019-10-07 13:20     ` Arvind Sankar
  0 siblings, 2 replies; 10+ messages in thread
From: Hans de Goede @ 2019-10-07  9:10 UTC (permalink / raw)
  To: Arvind Sankar, linux-kernel; +Cc: Ingo Molnar, x86

Hi,

On 07-10-2019 10:50, Hans de Goede wrote:
> Hi,
> 
> On 07-10-2019 05:09, Arvind Sankar wrote:
>> Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
>> memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
>> sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
>> according to git bisect.
> 
> Hmm, it (obviously) does build for me and using kexec still also works
> for me.
> 
> But it seems that you are right and that this should not build, weird.

Ok, I understand now, it seems that the kernel will happily build with
undefined symbols in the purgatory and my kexec testing did not hit
the sha256 check path (*) so it did not crash. I can reproduce this before my patch:

[hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform':
sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'

And I can confirm that it is gone after my patch:

[hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000

Regards,

Hans


*) I tried with a Fedora signed kernel, dunno how to trigger this if that does not
trigger it


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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07  9:10   ` Hans de Goede
@ 2019-10-07 13:09     ` Ingo Molnar
  2019-10-07 13:40       ` Hans de Goede
                         ` (2 more replies)
  2019-10-07 13:20     ` Arvind Sankar
  1 sibling, 3 replies; 10+ messages in thread
From: Ingo Molnar @ 2019-10-07 13:09 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Arvind Sankar, linux-kernel, x86, Borislav Petkov, Thomas Gleixner


* Hans de Goede <hdegoede@redhat.com> wrote:

> Hi,
> 
> On 07-10-2019 10:50, Hans de Goede wrote:
> > Hi,
> > 
> > On 07-10-2019 05:09, Arvind Sankar wrote:
> > > Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
> > > memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
> > > sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
> > > according to git bisect.
> > 
> > Hmm, it (obviously) does build for me and using kexec still also works
> > for me.
> > 
> > But it seems that you are right and that this should not build, weird.
> 
> Ok, I understand now, it seems that the kernel will happily build with
> undefined symbols in the purgatory and my kexec testing did not hit
> the sha256 check path (*) so it did not crash. I can reproduce this before my patch:
> 
> [hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
> ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
> ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform':
> sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'

I've applied your fix, but would it make sense to also integrate this 
linker test in the regular build with a second patch, to make sure 
something similar doesn't occur again?

Thanks,

	Ingo

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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07  9:10   ` Hans de Goede
  2019-10-07 13:09     ` Ingo Molnar
@ 2019-10-07 13:20     ` Arvind Sankar
  2019-10-07 16:56       ` Hans de Goede
  1 sibling, 1 reply; 10+ messages in thread
From: Arvind Sankar @ 2019-10-07 13:20 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Arvind Sankar, linux-kernel, Ingo Molnar, x86

On Mon, Oct 07, 2019 at 11:10:18AM +0200, Hans de Goede wrote:
> Hi,
> 
> On 07-10-2019 10:50, Hans de Goede wrote:
> > Hi,
> > 
> > On 07-10-2019 05:09, Arvind Sankar wrote:
> >> Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
> >> memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
> >> sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
> >> according to git bisect.
> > 
> > Hmm, it (obviously) does build for me and using kexec still also works
> > for me.
> > 
> > But it seems that you are right and that this should not build, weird.
> 
> Ok, I understand now, it seems that the kernel will happily build with
> undefined symbols in the purgatory and my kexec testing did not hit
> the sha256 check path (*) so it did not crash. I can reproduce this before my patch:

Yes -- this should really be fixed. purgatory build should fail if there
are undefined symbols, in fact the Makefile apparently is trying to do
something to catch undefined references?

LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib

This doesn't seem to actually do anything though. Anyone know of a way
to force ld to error if the resulting object would have undefined
symbols?

> 
> [hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
> ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
> ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform':
> sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'
> 
> And I can confirm that it is gone after my patch:
> 
> [hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
> ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
> 
> Regards,
> 
> Hans
> 
> 
> *) I tried with a Fedora signed kernel, dunno how to trigger this if that does not
> trigger it
> 

It triggers an error for me when loading the new image, i.e. when doing
# kexec -s -l new_image

Not sure what the difference is, mine is a custom configuration built
using mainline sources.

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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07 13:09     ` Ingo Molnar
@ 2019-10-07 13:40       ` Hans de Goede
  2019-10-07 13:55         ` Ingo Molnar
  2019-10-07 13:53       ` Ingo Molnar
  2019-10-07 14:07       ` Hans de Goede
  2 siblings, 1 reply; 10+ messages in thread
From: Hans de Goede @ 2019-10-07 13:40 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Arvind Sankar, linux-kernel, x86, Borislav Petkov, Thomas Gleixner

Hi,

On 07-10-2019 15:09, Ingo Molnar wrote:
> 
> * Hans de Goede <hdegoede@redhat.com> wrote:
> 
>> Hi,
>>
>> On 07-10-2019 10:50, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 07-10-2019 05:09, Arvind Sankar wrote:
>>>> Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
>>>> memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
>>>> sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
>>>> according to git bisect.
>>>
>>> Hmm, it (obviously) does build for me and using kexec still also works
>>> for me.
>>>
>>> But it seems that you are right and that this should not build, weird.
>>
>> Ok, I understand now, it seems that the kernel will happily build with
>> undefined symbols in the purgatory and my kexec testing did not hit
>> the sha256 check path (*) so it did not crash. I can reproduce this before my patch:
>>
>> [hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
>> ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
>> ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform':
>> sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'
> 
> I've applied your fix,

Thank you, unfortunately I was just minutes away from sending a v2
which adds a missing barrier call (not strictly necessary, more future
proofing).

Hopefully you can still pick up v2 instead, let me know if you want
an incremental patch instead.

Regards,

Hans


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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07 13:09     ` Ingo Molnar
  2019-10-07 13:40       ` Hans de Goede
@ 2019-10-07 13:53       ` Ingo Molnar
  2019-10-07 14:07       ` Hans de Goede
  2 siblings, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2019-10-07 13:53 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Arvind Sankar, linux-kernel, x86, Borislav Petkov, Thomas Gleixner


* Ingo Molnar <mingo@kernel.org> wrote:

> 
> * Hans de Goede <hdegoede@redhat.com> wrote:
> 
> > Hi,
> > 
> > On 07-10-2019 10:50, Hans de Goede wrote:
> > > Hi,
> > > 
> > > On 07-10-2019 05:09, Arvind Sankar wrote:
> > > > Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
> > > > memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
> > > > sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
> > > > according to git bisect.
> > > 
> > > Hmm, it (obviously) does build for me and using kexec still also works
> > > for me.
> > > 
> > > But it seems that you are right and that this should not build, weird.
> > 
> > Ok, I understand now, it seems that the kernel will happily build with
> > undefined symbols in the purgatory and my kexec testing did not hit
> > the sha256 check path (*) so it did not crash. I can reproduce this before my patch:
> > 
> > [hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
> > ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
> > ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform':
> > sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'
> 
> I've applied your fix, but would it make sense to also integrate this 
> linker test in the regular build with a second patch, to make sure 
> something similar doesn't occur again?

Note that I delayed the v1 fix and will wait for your v2 fix instead.

Thanks,

	Ingo

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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07 13:40       ` Hans de Goede
@ 2019-10-07 13:55         ` Ingo Molnar
  0 siblings, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2019-10-07 13:55 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Arvind Sankar, linux-kernel, x86, Borislav Petkov, Thomas Gleixner


* Hans de Goede <hdegoede@redhat.com> wrote:

> Hi,
> 
> On 07-10-2019 15:09, Ingo Molnar wrote:
> > 
> > * Hans de Goede <hdegoede@redhat.com> wrote:
> > 
> > > Hi,
> > > 
> > > On 07-10-2019 10:50, Hans de Goede wrote:
> > > > Hi,
> > > > 
> > > > On 07-10-2019 05:09, Arvind Sankar wrote:
> > > > > Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
> > > > > memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
> > > > > sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
> > > > > according to git bisect.
> > > > 
> > > > Hmm, it (obviously) does build for me and using kexec still also works
> > > > for me.
> > > > 
> > > > But it seems that you are right and that this should not build, weird.
> > > 
> > > Ok, I understand now, it seems that the kernel will happily build with
> > > undefined symbols in the purgatory and my kexec testing did not hit
> > > the sha256 check path (*) so it did not crash. I can reproduce this before my patch:
> > > 
> > > [hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
> > > ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
> > > ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform':
> > > sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'
> > 
> > I've applied your fix,
> 
> Thank you, unfortunately I was just minutes away from sending a v2
> which adds a missing barrier call (not strictly necessary, more future
> proofing).
> 
> Hopefully you can still pick up v2 instead, let me know if you want
> an incremental patch instead.

Yeah, our mails crossed: I noticed that and didn't push out your fix, so 
all should be good. Take your time.

Thanks,

	Ingo

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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07 13:09     ` Ingo Molnar
  2019-10-07 13:40       ` Hans de Goede
  2019-10-07 13:53       ` Ingo Molnar
@ 2019-10-07 14:07       ` Hans de Goede
  2 siblings, 0 replies; 10+ messages in thread
From: Hans de Goede @ 2019-10-07 14:07 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Arvind Sankar, linux-kernel, x86, Borislav Petkov, Thomas Gleixner

Hi,

On 07-10-2019 15:09, Ingo Molnar wrote:
> 
> * Hans de Goede <hdegoede@redhat.com> wrote:
> 
>> Hi,
>>
>> On 07-10-2019 10:50, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 07-10-2019 05:09, Arvind Sankar wrote:
>>>> Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
>>>> memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
>>>> sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
>>>> according to git bisect.
>>>
>>> Hmm, it (obviously) does build for me and using kexec still also works
>>> for me.
>>>
>>> But it seems that you are right and that this should not build, weird.
>>
>> Ok, I understand now, it seems that the kernel will happily build with
>> undefined symbols in the purgatory and my kexec testing did not hit
>> the sha256 check path (*) so it did not crash. I can reproduce this before my patch:
>>
>> [hans@shalem linux]$ ld arch/x86/purgatory/purgatory.ro
>> ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
>> ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform':
>> sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'
> 
> I've applied your fix, 

I already answered this bit.

> but would it make sense to also integrate this
> linker test in the regular build with a second patch, to make sure
> something similar doesn't occur again?

But I forgot to answer this part, yes I will look into making the build
fail as soon as we have the fix for this in place for 5.4 .

Regards,

Hans


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

* Re: kexec breaks with 5.4 due to memzero_explicit
  2019-10-07 13:20     ` Arvind Sankar
@ 2019-10-07 16:56       ` Hans de Goede
  0 siblings, 0 replies; 10+ messages in thread
From: Hans de Goede @ 2019-10-07 16:56 UTC (permalink / raw)
  To: Arvind Sankar; +Cc: linux-kernel, Ingo Molnar, x86

Hi,

On 07-10-2019 15:20, Arvind Sankar wrote:
> On Mon, Oct 07, 2019 at 11:10:18AM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 07-10-2019 10:50, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 07-10-2019 05:09, Arvind Sankar wrote:
>>>> Hi, arch/x86/purgatory/purgatory.ro has an undefined symbol
>>>> memzero_explicit. This has come from commit 906a4bb97f5d ("crypto:
>>>> sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit")
>>>> according to git bisect.
>>>
>>> Hmm, it (obviously) does build for me and using kexec still also works
>>> for me.
>>>
>>> But it seems that you are right and that this should not build, weird.
>>
>> Ok, I understand now, it seems that the kernel will happily build with
>> undefined symbols in the purgatory and my kexec testing did not hit
>> the sha256 check path (*) so it did not crash. I can reproduce this before my patch:
> 
> Yes -- this should really be fixed. purgatory build should fail if there
> are undefined symbols, in fact the Makefile apparently is trying to do
> something to catch undefined references?
> 
> LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
> 
> This doesn't seem to actually do anything though. Anyone know of a way
> to force ld to error if the resulting object would have undefined
> symbols?

I've figured out a way to get an error for the missing symbol, I will
Cc you on the patch which I will post upstream soon.

I will also write a similar patch for s390 and post that upstream
(untested) separately.

Regards,

Hans


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

end of thread, other threads:[~2019-10-07 16:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07  3:09 kexec breaks with 5.4 due to memzero_explicit Arvind Sankar
2019-10-07  8:50 ` Hans de Goede
2019-10-07  9:10   ` Hans de Goede
2019-10-07 13:09     ` Ingo Molnar
2019-10-07 13:40       ` Hans de Goede
2019-10-07 13:55         ` Ingo Molnar
2019-10-07 13:53       ` Ingo Molnar
2019-10-07 14:07       ` Hans de Goede
2019-10-07 13:20     ` Arvind Sankar
2019-10-07 16:56       ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.