From: Thomas Gleixner <tglx@linutronix.de>
To: Andi Kleen <andi@firstfloor.org>
Cc: dwmw@amazon.co.uk, torvalds@linux-foundation.org,
linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
arjan.van.de.ven@intel.com, peterz@infradead.org,
Andi Kleen <ak@linux.intel.com>,
jeyu@kernel.org
Subject: Re: [PATCH v2] retpoline/module: Warn for missing retpoline in module
Date: Tue, 16 Jan 2018 21:56:26 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.20.1801162132410.2366@nanos> (raw)
In-Reply-To: <20180112221323.3304-1-andi@firstfloor.org>
On Fri, 12 Jan 2018, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> void stop_this_cpu(void *dummy);
> void df_debug(struct pt_regs *regs, long error_code);
> +
> +void disable_retpoline(void);
> +bool retpoline_enabled(void);
Can you please use a consistent name space? retpoline_ ... or such?
> +/* A module has been loaded. Disable reporting that we're good. */
> +void disable_retpoline(void)
> +{
> + spectre_v2_enabled = SPECTRE_V2_NONE;
I really don't like fiddling with that variable. That's just hackery. The
variable reflects the actual enabled mitigation state of the kernel proper.
> + pr_err("system may be vunerable to spectre\n");
> +}
> +
> +bool retpoline_enabled(void)
> +{
> + return spectre_v2_enabled != SPECTRE_V2_NONE;
> +}
That'll break once we get other mitigation variants.
> @@ -3020,7 +3020,13 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
> mod->name);
> add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
> }
> -
These newlines are there to separate stuff for readability sake.
> +#ifdef RETPOLINE
> + if (retpoline_enabled() && !get_modinfo(info, "retpoline")) {
> + pr_warn("%s: loading module not compiled with retpoline compiler.\n",
> + mod->name);
> + disable_retpoline();
> + }
> +#endif
This really can be done in a cleaner way.
in linux/module.h
#ifdef RETPOLINE
extern bool retpoline_module_ok(bool has_retpoline);
#else
static inline bool retpoline_module_ok(bool has_retpoline)
{
return true;
}
#endif
static void check_modinfo_retpoline(mod, info)
{
if (retpoline_module_ok(get_modinfo(info, "retpoline")))
return;
pr_warn("%s: loading module not compiled with retpoline compiler.\n",
mod->name);
}
That only needs one function and that one can take care of setting a
variable in the spectre code which then influences the sysfs output.
And that output should not be "Vulnerable" like you force with the hack
above. It actually should tell WHY it is vulnerable despite having had
protection in place before the module was loaded.
Thanks,
tglx
next prev parent reply other threads:[~2018-01-16 20:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 22:13 Andi Kleen
2018-01-16 20:56 ` Thomas Gleixner [this message]
2018-01-16 20:59 ` Andi Kleen
2018-01-16 21:11 ` Van De Ven, Arjan
2018-01-16 21:24 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1801162132410.2366@nanos \
--to=tglx@linutronix.de \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=arjan.van.de.ven@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=jeyu@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®