Skip to content

Commit e9e0cdc

Browse files
committed
x86/bugs: Expose /sys/../spec_store_bypass
Add the sysfs file for the new vulerability. It does not do much except show the words 'Vulnerable' for recent x86 cores. Intel cores prior to family 6 are known not to be vulnerable, and so are some Atoms and some Xeon Phi. It assumes that older Cyrix, Centaur, etc. cores are immune. Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> (cherry picked from commit c456442) Orabug: 28034177 CVE: CVE-2018-3639 Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Mihai Carabas <[email protected]> Reviewed-by: Mihai Carabas <[email protected]> Reviewed-by: John Haxby <[email protected]> Reviewed-by: Darren Kenny <[email protected]>
1 parent e4073d2 commit e9e0cdc

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ What: /sys/devices/system/cpu/vulnerabilities
378378
/sys/devices/system/cpu/vulnerabilities/meltdown
379379
/sys/devices/system/cpu/vulnerabilities/spectre_v1
380380
/sys/devices/system/cpu/vulnerabilities/spectre_v2
381+
/sys/devices/system/cpu/vulnerabilities/spec_store_bypass
381382
Date: January 2018
382383
Contact: Linux kernel mailing list <[email protected]>
383384
Description: Information about CPU vulnerabilities

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,5 +364,6 @@
364364
#define X86_BUG_CPU_MELTDOWN X86_BUG(14) /* CPU is affected by meltdown attack and needs kernel page table isolation */
365365
#define X86_BUG_SPECTRE_V1 X86_BUG(15) /* CPU is affected by Spectre variant 1 attack with conditional branches */
366366
#define X86_BUG_SPECTRE_V2 X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
367+
#define X86_BUG_SPEC_STORE_BYPASS X86_BUG(17) /* CPU is affected by speculative store bypass attack */
367368

368369
#endif /* _ASM_X86_CPUFEATURES_H */

arch/x86/kernel/cpu/bugs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,4 +638,9 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
638638
{
639639
return cpu_show_common(dev, attr, buf, X86_BUG_SPECTRE_V2);
640640
}
641+
642+
ssize_t cpu_show_spec_store_bypass(struct device *dev, struct device_attribute *attr, char *buf)
643+
{
644+
return cpu_show_common(dev, attr, buf, X86_BUG_SPEC_STORE_BYPASS);
645+
}
641646
#endif

arch/x86/kernel/cpu/common.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,10 +952,33 @@ static const __initconst struct x86_cpu_id cpu_no_meltdown[] = {
952952
{}
953953
};
954954

955+
static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = {
956+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PINEVIEW },
957+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_LINCROFT },
958+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PENWELL },
959+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CLOVERVIEW },
960+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CEDARVIEW },
961+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1 },
962+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
963+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT2 },
964+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_MERRIFIELD },
965+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_CORE_YONAH },
966+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL },
967+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM },
968+
{ X86_VENDOR_CENTAUR, 5, },
969+
{ X86_VENDOR_INTEL, 5, },
970+
{ X86_VENDOR_NSC, 5, },
971+
{ X86_VENDOR_ANY, 4, },
972+
{}
973+
};
974+
955975
static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
956976
{
957977
u64 ia32_cap = 0;
958978

979+
if (!x86_match_cpu(cpu_no_spec_store_bypass))
980+
setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
981+
959982
if (x86_match_cpu(cpu_no_speculation))
960983
return;
961984

drivers/base/cpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,22 @@ ssize_t __weak cpu_show_spectre_v2(struct device *dev,
521521
return sprintf(buf, "Not affected\n");
522522
}
523523

524+
ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
525+
struct device_attribute *attr, char *buf)
526+
{
527+
return sprintf(buf, "Not affected\n");
528+
}
529+
524530
static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
525531
static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);
526532
static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
533+
static DEVICE_ATTR(spec_store_bypass, 0444, cpu_show_spec_store_bypass, NULL);
527534

528535
static struct attribute *cpu_root_vulnerabilities_attrs[] = {
529536
&dev_attr_meltdown.attr,
530537
&dev_attr_spectre_v1.attr,
531538
&dev_attr_spectre_v2.attr,
539+
&dev_attr_spec_store_bypass.attr,
532540
NULL
533541
};
534542

include/linux/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ extern ssize_t cpu_show_spectre_v1(struct device *dev,
5353
struct device_attribute *attr, char *buf);
5454
extern ssize_t cpu_show_spectre_v2(struct device *dev,
5555
struct device_attribute *attr, char *buf);
56+
extern ssize_t cpu_show_spec_store_bypass(struct device *dev,
57+
struct device_attribute *attr, char *buf);
5658

5759
extern __printf(4, 5)
5860
struct device *cpu_device_create(struct device *parent, void *drvdata,

0 commit comments

Comments
 (0)