Skip to contentSkip to conversation

x86/boot: Correctly deeclare error() as noreturn

PATCH New Kees Cook 2 participants 2 messages May 6, 2017 – May 7, 2017 x86

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 x86/boot: Correctly deeclare error() as noreturn

The compressed boot function error() is used to halt execution, but it wasn't marked with "noreturn". This fixes that in preparation for supporting kernel FORTIFY_SOURCE, which uses the noreturn annotation on panic, and calls error(). GCC would warn about a noreturn function calling a non-noreturn function:

arch/x86/boot/compressed/misc.c: In function ‘fortify_panic’:
arch/x86/boot/compressed/misc.c:416:1: warning: ‘noreturn’ function does return
}
^

Cc Daniel Micay <[email protected]>
---
 arch/x86/boot/compressed/error.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/boot/compressed/error.h +3 -1
index 2e59dac07f9e..d732e608e3af 100644
@@ -1,7 +1,9 @@
 #ifndef BOOT_COMPRESSED_ERROR_H
 #define BOOT_COMPRESSED_ERROR_H
 
+#include <linux/compiler.h>
+
 void warn(char *m);
-void error(char *m);
+void error(char *m) __noreturn;
 
 #endif /* BOOT_COMPRESSED_ERROR_H */
Signature · 6 lines
2.7.4


-- 
Kees Cook
Pixel Security
#1 lore raw

[tip:x86/urgent] x86/boot: Declare error() as noreturn

x86/boot: Declare error() as noreturn
Commit-ID:  60854a12d281e2fa25662fa32ac8022bbff17432
Gitweb:     http://git.kernel.org/tip/60854a12d281e2fa25662fa32ac8022bbff17432
Author:     Kees Cook <[email protected]>
AuthorDate: Fri, 5 May 2017 21:51:16 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 7 May 2017 10:59:05 +0200

x86/boot: Declare error() as noreturn

The compressed boot function error() is used to halt execution, but it wasn't marked with "noreturn". This fixes that in preparation for supporting kernel FORTIFY_SOURCE, which uses the noreturn annotation on panic, and calls error(). GCC would warn about a noreturn function calling a non-noreturn function:

arch/x86/boot/compressed/misc.c: In function ‘fortify_panic’:
arch/x86/boot/compressed/misc.c:416:1: warning: ‘noreturn’ function does return
}
^

---
 arch/x86/boot/compressed/error.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/boot/compressed/error.h +3 -1
index 2e59dac..d732e60 100644
@@ -1,7 +1,9 @@
 #ifndef BOOT_COMPRESSED_ERROR_H
 #define BOOT_COMPRESSED_ERROR_H
 
+#include <linux/compiler.h>
+
 void warn(char *m);
-void error(char *m);
+void error(char *m) __noreturn;
 
 #endif /* BOOT_COMPRESSED_ERROR_H */