Changes in 4.9.306 x86/speculation: Add RETPOLINE_AMD support to the inline asm CALL_NOSPEC variant x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support x86/retpoline: Remove minimal retpoline support Documentation: Add section about CPU vulnerabilities for Spectre Documentation: Add swapgs description to the Spectre v1 documentation Documentation: refer to config RANDOMIZE_BASE for kernel address-space randomization x86/speculation: Merge one test in spectre_v2_user_select_mitigation() x86,bugs: Unconditionally allow spectre_v2=retpoline,amd x86/speculation: Rename RETPOLINE_AMD to RETPOLINE_LFENCE x86/speculation: Add eIBRS + Retpoline options Documentation/hw-vuln: Update spectre doc x86/speculation: Include unprivileged eBPF status in Spectre v2 mitigation reporting x86/speculation: Use generic retpoline by default on AMD x86/speculation: Update link to AMD speculation whitepaper x86/speculation: Warn about Spectre v2 LFENCE mitigation x86/speculation: Warn about eIBRS + LFENCE + Unprivileged eBPF + SMT arm/arm64: Provide a wrapper for SMCCC 1.1 calls arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() ARM: report Spectre v2 status through sysfs ARM: early traps initialisation ARM: use LOADADDR() to get load address of sections ARM: Spectre-BHB workaround ARM: include unprivileged BPF status in Spectre V2 reporting ARM: fix build error when BPF_SYSCALL is disabled ARM: fix co-processor register typo ARM: Do not use NOCROSSREFS directive with ld.lld x86/build: Fix compiler support check for CONFIG_RETPOLINE x86, modpost: Replace last remnants of RETPOLINE with CONFIG_RETPOLINE ARM: fix build warning in proc-v7-bugs.c xen/xenbus: don't let xenbus_grant_ring() remove grants in error case xen/grant-table: add gnttab_try_end_foreign_access() xen/blkfront: don't use gnttab_query_foreign_access() for mapped status xen/netfront: don't use gnttab_query_foreign_access() for mapped status xen/scsifront: don't use gnttab_query_foreign_access() for mapped status xen/gntalloc: don't use gnttab_query_foreign_access() xen: remove gnttab_query_foreign_access() xen/gnttab: fix gnttab_end_foreign_access() without page specified xen/netfront: react properly to failing gnttab_end_foreign_access_ref() Linux 4.9.306 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I8083a622bda3bf4418f266a34c96d8175bc5e933
72 lines
1.5 KiB
C
72 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
#include <linux/bpf.h>
|
|
#include <linux/cpu.h>
|
|
#include <linux/device.h>
|
|
|
|
#include <asm/spectre.h>
|
|
|
|
static bool _unprivileged_ebpf_enabled(void)
|
|
{
|
|
#ifdef CONFIG_BPF_SYSCALL
|
|
return !sysctl_unprivileged_bpf_disabled;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr,
|
|
char *buf)
|
|
{
|
|
return sprintf(buf, "Mitigation: __user pointer sanitization\n");
|
|
}
|
|
|
|
static unsigned int spectre_v2_state;
|
|
static unsigned int spectre_v2_methods;
|
|
|
|
void spectre_v2_update_state(unsigned int state, unsigned int method)
|
|
{
|
|
if (state > spectre_v2_state)
|
|
spectre_v2_state = state;
|
|
spectre_v2_methods |= method;
|
|
}
|
|
|
|
ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr,
|
|
char *buf)
|
|
{
|
|
const char *method;
|
|
|
|
if (spectre_v2_state == SPECTRE_UNAFFECTED)
|
|
return sprintf(buf, "%s\n", "Not affected");
|
|
|
|
if (spectre_v2_state != SPECTRE_MITIGATED)
|
|
return sprintf(buf, "%s\n", "Vulnerable");
|
|
|
|
if (_unprivileged_ebpf_enabled())
|
|
return sprintf(buf, "Vulnerable: Unprivileged eBPF enabled\n");
|
|
|
|
switch (spectre_v2_methods) {
|
|
case SPECTRE_V2_METHOD_BPIALL:
|
|
method = "Branch predictor hardening";
|
|
break;
|
|
|
|
case SPECTRE_V2_METHOD_ICIALLU:
|
|
method = "I-cache invalidation";
|
|
break;
|
|
|
|
case SPECTRE_V2_METHOD_SMC:
|
|
case SPECTRE_V2_METHOD_HVC:
|
|
method = "Firmware call";
|
|
break;
|
|
|
|
case SPECTRE_V2_METHOD_LOOP8:
|
|
method = "History overwrite";
|
|
break;
|
|
|
|
default:
|
|
method = "Multiple mitigations";
|
|
break;
|
|
}
|
|
|
|
return sprintf(buf, "Mitigation: %s\n", method);
|
|
}
|