Skip to content

Commit

Permalink
bug: Have __warn() prototype defined unconditionally
Browse files Browse the repository at this point in the history
The __warn() prototype is declared in CONFIG_BUG scope but the function
definition in panic.c is unconditional. The IBT enablement started using
it unconditionally but a CONFIG_X86_KERNEL_IBT=y, CONFIG_BUG=n .config
will trigger a

  arch/x86/kernel/traps.c: In function ‘__exc_control_protection’:
  arch/x86/kernel/traps.c:249:17: error: implicit declaration of function \
  	  ‘__warn’; did you mean ‘pr_warn’? [-Werror=implicit-function-declaration]

Pull up the declarations so that they're unconditionally visible too.

  [ bp: Rewrite commit message. ]

Fixes: 991625f ("x86/ibt: Add IBT feature, MSR and #CP handling")
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20220426032007.510245-1-starzhangzsd@gmail.com
  • Loading branch information
Shida Zhang authored and Borislav Petkov committed Apr 26, 2022
1 parent 4cdfc11 commit 1fa568e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/asm-generic/bug.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
#include <linux/panic.h>
#include <linux/printk.h>

struct warn_args;
struct pt_regs;

void __warn(const char *file, int line, void *caller, unsigned taint,
struct pt_regs *regs, struct warn_args *args);

#ifdef CONFIG_BUG

#ifdef CONFIG_GENERIC_BUG
Expand Down Expand Up @@ -110,11 +116,6 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
#endif

/* used internally by panic.c */
struct warn_args;
struct pt_regs;

void __warn(const char *file, int line, void *caller, unsigned taint,
struct pt_regs *regs, struct warn_args *args);

#ifndef WARN_ON
#define WARN_ON(condition) ({ \
Expand Down

0 comments on commit 1fa568e

Please sign in to comment.