From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227B2+MfY1laWPh/Tag8y5u21Y/SBLR8l1JOgtNiWIbE91i7Qa69FYPQYEOU7fzn+kWGCuSP ARC-Seal: i=1; a=rsa-sha256; t=1516926006; cv=none; d=google.com; s=arc-20160816; b=J5RVA8SyNAVx4qQ3OgZyAvdztCDP0EdJlDp74e/X7oAEK21QYYtjCSSLVGEk7VMwx7 wPfNsffW/mElDrPuHmF8iRQnlm30je1RjJXSw3PnSxgolr5r2HYGmZfw+TIj9gFXEklm 2ovjiQmYCmf04Yt9hWut41lHx07BDf1B0h1FwbJ1kF54js8zMt3bwdEtGhhBc0Eu69Rh YmfgIE2X61pVhOW2r5CawEAYR0wvcpehEhIY9FuRDdBb3RNUY4ZNmc+PVf7f+lo11N+1 unABsn0Rfw2Kvox0pqYtmE7Edh+6KAEFHVbYTSZLvo8bw4vnyknZ2ZHVD+a8s4spaas+ DzLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dmarc-filter :arc-authentication-results; bh=k7se7+0cf1Cxc/OI0iH7VpemV2mUruZwHxrvKZyguRs=; b=0a4lW5PHMbl8C7Eq8NDueFOQwW5ZYsd+Sgb917mRSoTnxJnBS9LC4JnYuj0gPVm7mg NJ1gHBcTJW9l/1gGP/RKDt4BMNiRCdOXxmmmQLc3rkvm3jnQ//BV87eFHdG8KWMG3QJV DItP8WuKMiaUWQBcPmNU3tyol0M4qw5rA3jLVvrgpBT3H73DiQS98ZNZMXWae0JI47UA Jvvcb+/GR/wI0C6CMhVMjstwkrjp4ZPnTV+TQCi9/8Pnf91FvQkgoD0+Wkmktp1NvpEi rb3Fhr1RB+nHg2yh92dI3cFPgy6AafTc9qzcFbhlf1TZiyyiqDT5jdzO8uyf/6K5fEnp 1yyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of jeyu@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=jeyu@kernel.org Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of jeyu@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=jeyu@kernel.org DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E10C621795 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jeyu@kernel.org Date: Fri, 26 Jan 2018 01:20:00 +0100 From: Jessica Yu To: Andi Kleen Cc: Linus Torvalds , Greg Kroah-Hartman , Jiri Kosina , Thomas Gleixner , David Woodhouse , Rusty Russell , "Van De Ven, Arjan" , Linux Kernel Mailing List Subject: Re: [PATCH] Revert "module: Add retpoline tag to VERMAGIC" Message-ID: <20180126001958.vcqsxcvwfrvdmsf2@redbean.localdomain> References: <20180124142817.GA23797@kroah.com> <20180124181735.GB26209@tassilo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180124181735.GB26209@tassilo.jf.intel.com> X-OS: Linux redbean 4.14.11-200.fc26.x86_64 x86_64 User-Agent: NeoMutt/20171215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcSW1wb3J0YW50Ig==?= X-GMAIL-THRID: =?utf-8?q?1590489149252174297?= X-GMAIL-MSGID: =?utf-8?q?1590612204415619908?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: +++ Andi Kleen [24/01/18 10:17 -0800]: >On Wed, Jan 24, 2018 at 09:00:48AM -0800, Linus Torvalds wrote: >> On Wed, Jan 24, 2018 at 6:28 AM, Greg Kroah-Hartman >> wrote: >> > >> > Linus, if there are no objections, can you apply this revert to your >> > tree now so this doesn't get into 4.15? >> >> Applied. > >So can we get the warning replacement? It would be good to have some >kind of solution. > >-Andi > >---- > >retpoline/module: Warn for missing retpoline in module > >There's a risk that a kernel that has full retpoline mitigations >becomes vulnerable when a module gets loaded that hasn't been >compiled with the right compiler or the right option. > >We cannot fix it, but should at least warn the user when that >happens. > >When the a module hasn't been compiled with a retpoline >aware compiler, print a warning and change the SPECTRE_V2 >mitigation mode to show the system is vulnerable now. > >For modules it is checked at compile time, however it cannot >check assembler or other non compiled objects used in the module link. > >v2: Change warning message >v3: Port to latest tree >v4: Remove tainting So I thought distros wanted the module taint after all, as Greg mentioned, or is that still overkill? Would the printed warning be sufficient for the distro folks? >Cc: jeyu@kernel.org >Signed-off-by: Andi Kleen >Signed-off-by: David Woodhouse > >diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h >index 9c18da64daa9..ea707c91bd8c 100644 >--- a/arch/x86/include/asm/processor.h >+++ b/arch/x86/include/asm/processor.h >@@ -970,4 +970,8 @@ bool xen_set_default_idle(void); > > void stop_this_cpu(void *dummy); > void df_debug(struct pt_regs *regs, long error_code); >+ >+void disable_retpoline(void); >+bool retpoline_enabled(void); >+ > #endif /* _ASM_X86_PROCESSOR_H */ >diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c >index e4dc26185aa7..9064b20473a7 100644 >--- a/arch/x86/kernel/cpu/bugs.c >+++ b/arch/x86/kernel/cpu/bugs.c >@@ -93,6 +93,18 @@ static const char *spectre_v2_strings[] = { > > static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE; > >+/* A module has been loaded. Disable reporting that we're good. */ >+void disable_retpoline(void) >+{ >+ spectre_v2_enabled = SPECTRE_V2_NONE; >+ pr_err("system may be vunerable to spectre\n"); >+} >+ >+bool retpoline_enabled(void) >+{ >+ return spectre_v2_enabled != SPECTRE_V2_NONE; >+} >+ > static void __init spec2_print_if_insecure(const char *reason) > { > if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) >diff --git a/kernel/module.c b/kernel/module.c >index de66ec825992..136ea6cabec6 100644 >--- a/kernel/module.c >+++ b/kernel/module.c >@@ -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); > } >- >+#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 > if (get_modinfo(info, "staging")) { > add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK); > pr_warn("%s: module is from the staging directory, the quality " >diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c >index 98314b400a95..54deaa1066cf 100644 >--- a/scripts/mod/modpost.c >+++ b/scripts/mod/modpost.c >@@ -2165,6 +2165,14 @@ static void add_intree_flag(struct buffer *b, int is_intree) > buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); > } > >+/* Cannot check for assembler */ >+static void add_retpoline(struct buffer *b) >+{ >+ buf_printf(b, "\n#ifdef RETPOLINE\n"); >+ buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n"); >+ buf_printf(b, "#endif\n"); >+} >+ > static void add_staging_flag(struct buffer *b, const char *name) > { > static const char *staging_dir = "drivers/staging"; >@@ -2506,6 +2514,7 @@ int main(int argc, char **argv) > err |= check_modname_len(mod); > add_header(&buf, mod); > add_intree_flag(&buf, !external_module); >+ add_retpoline(&buf); > add_staging_flag(&buf, mod->name); > err |= add_versions(&buf, mod); > add_depends(&buf, mod, modules); >