Skip to contentSkip to conversation

arm: decompressor: mark error() as __noreturn

PATCH In review Arnd Bergmann 3 participants 4 messages Apr 4, 2018 – Apr 5, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: decompressor: mark error() as __noreturn

gcc complains about fortify_panic() possibly returning:

arch/arm/boot/compressed/misc.c: In function 'fortify_panic':
arch/arm/boot/compressed/misc.c:167:1: error: 'noreturn' function does return [-Werror]

This annotates the error() function as __noreturn, which lets gcc see in all configurations that it fortify_panic() cannot return either.

Fixes ee333554fed5 ("ARM: 8749/1: Kconfig: Add ARCH_HAS_FORTIFY_SOURCE")
---
 arch/arm/boot/compressed/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/compressed/misc.c +1 -1
index 009db7d275f8..313a587d656b 100644
@@ -24,7 +24,7 @@ unsigned int __machine_arch_type;
 #include <linux/linkage.h>
 
 static void putstr(const char *ptr);
-extern void error(char *x);
+extern void error(char *x) __noreturn;
 
 #include CONFIG_UNCOMPRESS_INCLUDE
 
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

gcc complains about fortify_panic() possibly returning:

arch/arm/boot/compressed/misc.c: In function 'fortify_panic':
arch/arm/boot/compressed/misc.c:167:1: error: 'noreturn' function does return [-Werror]

This annotates the error() function as __noreturn, which lets gcc see in all configurations that it fortify_panic() cannot return either.

Fixes ee333554fed5 ("ARM: 8749/1: Kconfig: Add ARCH_HAS_FORTIFY_SOURCE")

-Kees

Quoted 20 lines
---
 arch/arm/boot/compressed/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/compressed/misc.c +1 -2
index 009db7d275f8..313a587d656b 100644
@@ -24,7 +24,7 @@ unsigned int __machine_arch_type;
 #include <linux/linkage.h>
 
 static void putstr(const char *ptr);
-extern void error(char *x);
+extern void error(char *x) __noreturn;
 
 #include CONFIG_UNCOMPRESS_INCLUDE
 
--

2.9.0

Signature · 2 lines
Kees Cook
Pixel Security
#2 lore raw
Quoted 6 lines · Kees Cook
Quoted 5 lines · Arnd Bergmann

gcc complains about fortify_panic() possibly returning:

arch/arm/boot/compressed/misc.c: In function 'fortify_panic':
arch/arm/boot/compressed/misc.c:167:1: error: 'noreturn' function does return [-Werror]

Quoted 7 lines
Quoted 5 lines

This annotates the error() function as __noreturn, which lets gcc see in all configurations that it fortify_panic() cannot return either.

Fixes ee333554fed5 ("ARM: 8749/1: Kconfig: Add ARCH_HAS_FORTIFY_SOURCE")

I'd actually prefer a more robust solution to this - error() is used in different files, each with their own separate prototype, which is error-prone. The same goes for a few other variables. The following is IMHO a more complete (and thus larger) patch:

 arch/arm/boot/compressed/decompress.c |  5 +----
 arch/arm/boot/compressed/misc.c       |  2 +-
 arch/arm/boot/compressed/misc.h       | 10 ++++++++++
 3 files changed, 12 insertions(+), 5 deletions(-)
arch/arm/boot/compressed/decompress.c +1 -4
index a2ac3fe7dbf8..c16c1829a5e4 100644
@@ -6,10 +6,7 @@
 #include <linux/stddef.h>	/* for NULL */
 #include <linux/linkage.h>
 #include <asm/string.h>
-
-extern unsigned long free_mem_ptr;
-extern unsigned long free_mem_end_ptr;
-extern void error(char *);
+#include "misc.h"
 
 #define STATIC static
 #define STATIC_RW_DATA	/* non-static please */
arch/arm/boot/compressed/misc.c +1 -1
index a3ded2a64b32..e94c84dded6c 100644
@@ -22,9 +22,9 @@ unsigned int __machine_arch_type;
 #include <linux/compiler.h>	/* for inline */
 #include <linux/types.h>
 #include <linux/linkage.h>
+#include "misc.h"
 
 static void putstr(const char *ptr);
-extern void error(char *x);
 
 #include CONFIG_UNCOMPRESS_INCLUDE
 
arch/arm/boot/compressed/misc.h new file +10 -0
new file mode 100644
index 000000000000..c958dccd1d97
@@ -0,0 +1,10 @@
+#ifndef MISC_H
+#define MISC_H
+
+#include <linux/compiler.h>
+
+void error(char *x) __noreturn;
+extern unsigned long free_mem_ptr;
+extern unsigned long free_mem_end_ptr;
+
+#endif
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
author Acked-by
#3 lore raw
Quoted 13 lines · Russell King - ARM Linux
Quoted 12 lines · Kees Cook
Quoted 10 lines · Arnd Bergmann

gcc complains about fortify_panic() possibly returning:

arch/arm/boot/compressed/misc.c: In function 'fortify_panic':
arch/arm/boot/compressed/misc.c:167:1: error: 'noreturn' function does return [-Werror]

This annotates the error() function as __noreturn, which lets gcc see in all configurations that it fortify_panic() cannot return either.

Fixes ee333554fed5 ("ARM: 8749/1: Kconfig: Add ARCH_HAS_FORTIFY_SOURCE")
Quoted 6 lines
Quoted 1 line

I'd actually prefer a more robust solution to this - error() is used in different files, each with their own separate prototype, which is error-prone. The same goes for a few other variables. The following is IMHO a more complete (and thus larger) patch:

Right, much better.

I assume you'll just fold it into the original patch if you can, or apply it on top yourself.