Skip to contentSkip to conversation

x86/KASLR: use the right memcpy

PATCH In review Arnd Bergmann 3 participants 5 messages May 30, 2017 – May 31, 2017 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/KASLR: use the right memcpy

The decompressor has its own implementation of the string functions, but has to include the right header to get those, while implicitly including linux/string.h may result in a link error:

arch/x86/boot/compressed/kaslr.o: In function `choose_random_location':
kaslr.c:(.text+0xf51): undefined reference to `_mmx_memcpy'

This has appeared now as kaslr started using memcpy. Other files in the decompressor already do the same thing.

Fixes d52e7d5a952c ("x86/KASLR: Parse all 'memmap=' boot option entries")
---
 arch/x86/boot/compressed/kaslr.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/boot/compressed/kaslr.c +1 -0
index e0eba12bffe7..fe318b44f7b8 100644
@@ -30,6 +30,7 @@
 
 #include "misc.h"
 #include "error.h"
+#include "../string.h"
 
 #include <generated/compile.h>
 #include <linux/module.h>
Signature · 1 line
2.9.0
#1 lore raw
Quoted 4 lines · Arnd Bergmann

The decompressor has its own implementation of the string functions, but has to include the right header to get those, while implicitly including linux/string.h may result in a link error:

Quoted 8 lines

arch/x86/boot/compressed/kaslr.o: In function `choose_random_location':
kaslr.c:(.text+0xf51): undefined reference to `_mmx_memcpy'

This has appeared now as kaslr started using memcpy. Other files in the decompressor already do the same thing.

Fixes d52e7d5a952c ("x86/KASLR: Parse all 'memmap=' boot option entries")

Thanks for this fix, Arnd!

The linking error didn't happen when I tested the patch of d52e7d5a952c. Could you tell in what condition it will be triggered? Not sure if I should wait for this fix being merged and do a back porting, or can defer it if it's not risky.

Thanks
Baoquan

Quoted 19 lines
---
 arch/x86/boot/compressed/kaslr.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/boot/compressed/kaslr.c +1 -0
index e0eba12bffe7..fe318b44f7b8 100644
@@ -30,6 +30,7 @@
 
 #include "misc.h"
 #include "error.h"
+#include "../string.h"
 
 #include <generated/compile.h>
 #include <linux/module.h>
Signature · 1 line
2.9.0
#2 lore raw
Quoted 14 lines · Baoquan He
Quoted 4 lines · Arnd Bergmann

The decompressor has its own implementation of the string functions, but has to include the right header to get those, while implicitly including linux/string.h may result in a link error:

Quoted 8 lines

arch/x86/boot/compressed/kaslr.o: In function `choose_random_location':
kaslr.c:(.text+0xf51): undefined reference to `_mmx_memcpy'

This has appeared now as kaslr started using memcpy. Other files in the decompressor already do the same thing.

Fixes d52e7d5a952c ("x86/KASLR: Parse all 'memmap=' boot option entries")
Quoted 6 lines

Thanks for this fix, Arnd!

The linking error didn't happen when I tested the patch of d52e7d5a952c. Could you tell in what condition it will be triggered? Not sure if I should wait for this fix being merged and do a back porting, or can defer it if it's not risky.

It only happens on 32-bit kernels with CONFIG_X86_USE_3DNOW, maybe there are additional requirements.

Arnd

#3 lore raw
Quoted 17 lines · Arnd Bergmann
Quoted 16 lines · Baoquan He
Quoted 4 lines · Arnd Bergmann

The decompressor has its own implementation of the string functions, but has to include the right header to get those, while implicitly including linux/string.h may result in a link error:

Quoted 8 lines

arch/x86/boot/compressed/kaslr.o: In function `choose_random_location':
kaslr.c:(.text+0xf51): undefined reference to `_mmx_memcpy'

This has appeared now as kaslr started using memcpy. Other files in the decompressor already do the same thing.

Fixes d52e7d5a952c ("x86/KASLR: Parse all 'memmap=' boot option entries")

Thanks for this fix, Arnd!

Quoted 7 lines
Quoted 4 lines

The linking error didn't happen when I tested the patch of d52e7d5a952c. Could you tell in what condition it will be triggered? Not sure if I should wait for this fix being merged and do a back porting, or can defer it if it's not risky.

It only happens on 32-bit kernels with CONFIG_X86_USE_3DNOW, maybe there are additional requirements.

Checked code again, in commit d52e7d5a952c "#include "../boot.h" is removed. Not sure if that removal caused the 32-bit kernel link error. While I didn't see boot/string.h is included into the boot/boot.h.

#4 lore raw

[tip:x86/boot] x86/KASLR: Use the right memcpy() implementation

In reply to Arnd Bergmann
x86/KASLR: Use the right memcpy() implementation
Commit-ID:  5b8b9cf76add98e19ff8ceb4247c2920687591a0
Gitweb:     http://git.kernel.org/tip/5b8b9cf76add98e19ff8ceb4247c2920687591a0
Author:     Arnd Bergmann <[email protected]>
AuthorDate: Tue, 30 May 2017 11:14:17 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 31 May 2017 07:59:45 +0200

x86/KASLR: Use the right memcpy() implementation

The decompressor has its own implementation of the string functions, but has to include the right header to get those, while implicitly including linux/string.h may result in a link error:

arch/x86/boot/compressed/kaslr.o: In function `choose_random_location':
kaslr.c:(.text+0xf51): undefined reference to `_mmx_memcpy'

This has appeared now as KASLR started using memcpy(), via:

	d52e7d5a952c ("x86/KASLR: Parse all 'memmap=' boot option entries")

Other files in the decompressor already do the same thing.

---
 arch/x86/boot/compressed/kaslr.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/boot/compressed/kaslr.c +1 -0
index e0eba12..fe318b4 100644
@@ -30,6 +30,7 @@
 
 #include "misc.h"
 #include "error.h"
+#include "../string.h"
 
 #include <generated/compile.h>
 #include <linux/module.h>