Skip to content

Commit

Permalink
livepatch: handle ancient compilers with more grace
Browse files Browse the repository at this point in the history
We are aborting a build in case when gcc doesn't support fentry on x86_64
(regs->ip modification can't really reliably work with mcount).

This however breaks allmodconfig for people with older gccs that don't
support -mfentry.

Turn the build-time failure into runtime failure, resulting in the whole
infrastructure not being initialized if CC_USING_FENTRY is unset.

Reported-by: Andrew Morton <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
  • Loading branch information
Jiri Kosina committed Jan 9, 2015
1 parent 83ac237 commit b9dfe0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arch/x86/include/asm/livepatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
#include <linux/ftrace.h>

#ifdef CONFIG_LIVE_PATCHING
static inline int klp_check_compiler_support(void)
{
#ifndef CC_USING_FENTRY
#error Your compiler must support -mfentry for live patching to work
return 1;
#endif
return 0;
}
extern int klp_write_module_reloc(struct module *mod, unsigned long type,
unsigned long loc, unsigned long value);

Expand Down
6 changes: 6 additions & 0 deletions kernel/livepatch/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,12 @@ static int klp_init(void)
{
int ret;

ret = klp_check_compiler_support();
if (ret) {
pr_info("Your compiler is too old; turning off.\n");
return -EINVAL;
}

ret = register_module_notifier(&klp_module_nb);
if (ret)
return ret;
Expand Down

0 comments on commit b9dfe0b

Please sign in to comment.