lkml.org 
[lkml]   [2018]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4] retpoline/module: Warn for missing retpoline in module
From
Date
On 01/25/2018 03:50 PM, Andi Kleen wrote:

> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index 390b3dc3d438..8766e13efe80 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -11,6 +11,7 @@
> #include <linux/init.h>
> #include <linux/utsname.h>
> #include <linux/cpu.h>
> +#include <linux/module.h>
>
> #include <asm/nospec-branch.h>
> #include <asm/cmdline.h>
> @@ -94,6 +95,20 @@ static const char *spectre_v2_strings[] = {
>
> static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
>
> +static bool spectre_v2_bad_module;
> +
> +#ifdef RETPOLINE
> +bool retpoline_module_ok(bool has_retpoline)
> +{
> + if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline)
> + return true;
> +
> + pr_err("system may be vunerable to spectre_v2\n");

vulnerable

> + spectre_v2_bad_module = true;
> + return false;
> +}
> +#endif
> +
> static void __init spec2_print_if_insecure(const char *reason)
> {
> if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
> @@ -278,6 +293,7 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
> if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
> return sprintf(buf, "Not affected\n");
>
> - return sprintf(buf, "%s\n", spectre_v2_strings[spectre_v2_enabled]);
> + return sprintf(buf, "%s%s\n", spectre_v2_strings[spectre_v2_enabled],
> + spectre_v2_bad_module ? " but vulnerable module loaded" : "");
> }
> #endif


--
~Randy

\
 
 \ /
  Last update: 2018-01-26 00:54    [W:1.594 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site