Skip to contentSkip to conversation

mips: boot/compressed: use __NO_FORITFY

PATCH Superseded John Thomson 3 participants 3 messages Oct 30, 2022 – Oct 31, 2022 MIPS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: boot/compressed: use __NO_FORITFY

In the mips CONFIG_SYS_SUPPORTS_ZBOOT kernel, fix the compile error when using CONFIG_FORTIFY_SOURCE=y

LD vmlinuz
mipsel-openwrt-linux-musl-ld: arch/mips/boot/compressed/decompress.o: in function `decompress_kernel':
./include/linux/decompress/mm.h:(.text.decompress_kernel+0x177c):
undefined reference to `warn_slowpath_fmt'

kernel test robot helped identify this as related to fortify. The error appeared with commit 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")

Resolve this in the same style as commit cfecea6ead5f ("lib/string:
Move helper functions out of string.c")

Fixes 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")

---
not sure about the fixes tag:
compile error only occurs due to the fortify commit, but it looks like this change could have been part of the other commit identified in the
message: lib/string move helper functions?

---
 arch/mips/boot/compressed/decompress.c | 1 +
 1 file changed, 1 insertion(+)
arch/mips/boot/compressed/decompress.c +1 -0
index 5b38a802e101..c5dd415254d3 100644
@@ -9,6 +9,7 @@
 
 #define DISABLE_BRANCH_PROFILING
 
+#define __NO_FORTIFY
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
Signature · 1 line
2.37.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · John Thomson

In the mips CONFIG_SYS_SUPPORTS_ZBOOT kernel, fix the compile error when using CONFIG_FORTIFY_SOURCE=y

LD vmlinuz
mipsel-openwrt-linux-musl-ld: arch/mips/boot/compressed/decompress.o: in function `decompress_kernel':
./include/linux/decompress/mm.h:(.text.decompress_kernel+0x177c):
undefined reference to `warn_slowpath_fmt'

kernel test robot helped identify this as related to fortify. The error appeared with commit 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")

Resolve this in the same style as commit cfecea6ead5f ("lib/string:
Move helper functions out of string.c")

Quoted 8 lines
Fixes 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")

---
not sure about the fixes tag:
compile error only occurs due to the fortify commit, but it looks like this change could have been part of the other commit identified in the
message: lib/string move helper functions?

I think the Fixes tag is reasonable. Strictly speaking, it should likely be whatever added the memcpy() in decompress.c, but that's mostly nonsense, since nothing else had tripped yet. :)

The issue is that the memcpy() has a runtime length, so CONFIG_FORTIFY_SOURCE was inserting the logic for a runtime warning, which doesn't exist here. This is the correct fix (turning off FORTIFY in the early boot loader).

Signature · 1 line
Kees Cook
#2 lore raw
In reply to John Thomson
Quoted 20 lines · John Thomson

In the mips CONFIG_SYS_SUPPORTS_ZBOOT kernel, fix the compile error when using CONFIG_FORTIFY_SOURCE=y

LD vmlinuz
mipsel-openwrt-linux-musl-ld: arch/mips/boot/compressed/decompress.o: in function `decompress_kernel':
./include/linux/decompress/mm.h:(.text.decompress_kernel+0x177c):
undefined reference to `warn_slowpath_fmt'

kernel test robot helped identify this as related to fortify. The error appeared with commit 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")

Resolve this in the same style as commit cfecea6ead5f ("lib/string:
Move helper functions out of string.c")

Fixes 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")
Quoted 8 lines

---
not sure about the fixes tag:
compile error only occurs due to the fortify commit, but it looks like this change could have been part of the other commit identified in the
message: lib/string move helper functions?

---
  arch/mips/boot/compressed/decompress.c | 1 +
  1 file changed, 1 insertion(+)

Typo "__NO_FORTIFY" in subject.