Skip to content

Commit 25875aa

Browse files
author
Russell King (Oracle)
committed
ARM: include unprivileged BPF status in Spectre V2 reporting
The mitigations for Spectre-BHB are only applied when an exception is taken, but when unprivileged BPF is enabled, userspace can load BPF programs that can be used to exploit the problem. When unprivileged BPF is enabled, report the vulnerable status via the spectre_v2 sysfs file. Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent b9baf5c commit 25875aa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/arm/kernel/spectre.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
// SPDX-License-Identifier: GPL-2.0-only
2+
#include <linux/bpf.h>
23
#include <linux/cpu.h>
34
#include <linux/device.h>
45

56
#include <asm/spectre.h>
67

8+
static bool _unprivileged_ebpf_enabled(void)
9+
{
10+
#ifdef CONFIG_BPF_SYSCALL
11+
return !sysctl_unprivileged_bpf_disabled;
12+
#else
13+
return false
14+
#endif
15+
}
16+
717
ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr,
818
char *buf)
919
{
@@ -31,6 +41,9 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr,
3141
if (spectre_v2_state != SPECTRE_MITIGATED)
3242
return sprintf(buf, "%s\n", "Vulnerable");
3343

44+
if (_unprivileged_ebpf_enabled())
45+
return sprintf(buf, "Vulnerable: Unprivileged eBPF enabled\n");
46+
3447
switch (spectre_v2_methods) {
3548
case SPECTRE_V2_METHOD_BPIALL:
3649
method = "Branch predictor hardening";

0 commit comments

Comments
 (0)