Skip to content

Commit 272b86b

Browse files
committed
Merge tag 'x86_bugs_for_v6.5_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mitigation fixes from Borislav Petkov: "The first set of fallout fixes after the embargo madness. There will be another set next week too. - A first series of cleanups/unifications and documentation improvements to the SRSO and GDS mitigations code which got postponed to after the embargo date - Fix the SRSO aliasing addresses assertion so that the LLVM linker can parse it too" * tag 'x86_bugs_for_v6.5_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: driver core: cpu: Fix the fallback cpu_show_gds() name x86: Move gds_ucode_mitigated() declaration to header x86/speculation: Add cpu_show_gds() prototype driver core: cpu: Make cpu_show_not_affected() static x86/srso: Fix build breakage with the LLVM linker Documentation/srso: Document IBPB aspect and fix formatting driver core: cpu: Unify redundant silly stubs Documentation/hw-vuln: Unify filename specification in index
2 parents f8de32c + 3477144 commit 272b86b

File tree

7 files changed

+83
-113
lines changed

7 files changed

+83
-113
lines changed

Documentation/admin-guide/hw-vuln/index.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ are configurable at compile, boot or run time.
1313
l1tf
1414
mds
1515
tsx_async_abort
16-
multihit.rst
17-
special-register-buffer-data-sampling.rst
18-
core-scheduling.rst
19-
l1d_flush.rst
20-
processor_mmio_stale_data.rst
21-
cross-thread-rsb.rst
16+
multihit
17+
special-register-buffer-data-sampling
18+
core-scheduling
19+
l1d_flush
20+
processor_mmio_stale_data
21+
cross-thread-rsb
2222
srso
23-
gather_data_sampling.rst
23+
gather_data_sampling

Documentation/admin-guide/hw-vuln/srso.rst

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,42 +42,59 @@ The sysfs file showing SRSO mitigation status is:
4242

4343
The possible values in this file are:
4444

45-
- 'Not affected' The processor is not vulnerable
45+
* 'Not affected':
4646

47-
- 'Vulnerable: no microcode' The processor is vulnerable, no
48-
microcode extending IBPB functionality
49-
to address the vulnerability has been
50-
applied.
47+
The processor is not vulnerable
5148

52-
- 'Mitigation: microcode' Extended IBPB functionality microcode
53-
patch has been applied. It does not
54-
address User->Kernel and Guest->Host
55-
transitions protection but it does
56-
address User->User and VM->VM attack
57-
vectors.
49+
* 'Vulnerable: no microcode':
5850

59-
(spec_rstack_overflow=microcode)
51+
The processor is vulnerable, no microcode extending IBPB
52+
functionality to address the vulnerability has been applied.
6053

61-
- 'Mitigation: safe RET' Software-only mitigation. It complements
62-
the extended IBPB microcode patch
63-
functionality by addressing User->Kernel
64-
and Guest->Host transitions protection.
54+
* 'Mitigation: microcode':
6555

66-
Selected by default or by
67-
spec_rstack_overflow=safe-ret
56+
Extended IBPB functionality microcode patch has been applied. It does
57+
not address User->Kernel and Guest->Host transitions protection but it
58+
does address User->User and VM->VM attack vectors.
6859

69-
- 'Mitigation: IBPB' Similar protection as "safe RET" above
70-
but employs an IBPB barrier on privilege
71-
domain crossings (User->Kernel,
72-
Guest->Host).
60+
Note that User->User mitigation is controlled by how the IBPB aspect in
61+
the Spectre v2 mitigation is selected:
7362

74-
(spec_rstack_overflow=ibpb)
63+
* conditional IBPB:
64+
65+
where each process can select whether it needs an IBPB issued
66+
around it PR_SPEC_DISABLE/_ENABLE etc, see :doc:`spectre`
67+
68+
* strict:
69+
70+
i.e., always on - by supplying spectre_v2_user=on on the kernel
71+
command line
72+
73+
(spec_rstack_overflow=microcode)
74+
75+
* 'Mitigation: safe RET':
76+
77+
Software-only mitigation. It complements the extended IBPB microcode
78+
patch functionality by addressing User->Kernel and Guest->Host
79+
transitions protection.
80+
81+
Selected by default or by spec_rstack_overflow=safe-ret
82+
83+
* 'Mitigation: IBPB':
84+
85+
Similar protection as "safe RET" above but employs an IBPB barrier on
86+
privilege domain crossings (User->Kernel, Guest->Host).
87+
88+
(spec_rstack_overflow=ibpb)
89+
90+
* 'Mitigation: IBPB on VMEXIT':
91+
92+
Mitigation addressing the cloud provider scenario - the Guest->Host
93+
transitions only.
94+
95+
(spec_rstack_overflow=ibpb-vmexit)
7596

76-
- 'Mitigation: IBPB on VMEXIT' Mitigation addressing the cloud provider
77-
scenario - the Guest->Host transitions
78-
only.
7997

80-
(spec_rstack_overflow=ibpb-vmexit)
8198

8299
In order to exploit vulnerability, an attacker needs to:
83100

arch/x86/include/asm/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,4 +731,6 @@ bool arch_is_platform_page(u64 paddr);
731731
#define arch_is_platform_page arch_is_platform_page
732732
#endif
733733

734+
extern bool gds_ucode_mitigated(void);
735+
734736
#endif /* _ASM_X86_PROCESSOR_H */

arch/x86/kernel/vmlinux.lds.S

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,17 @@ INIT_PER_CPU(irq_stack_backing_store);
529529

530530
#ifdef CONFIG_CPU_SRSO
531531
/*
532-
* GNU ld cannot do XOR so do: (A | B) - (A & B) in order to compute the XOR
532+
* GNU ld cannot do XOR until 2.41.
533+
* https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f6f78318fca803c4907fb8d7f6ded8295f1947b1
534+
*
535+
* LLVM lld cannot do XOR until lld-17.
536+
* https://github.com/llvm/llvm-project/commit/fae96104d4378166cbe5c875ef8ed808a356f3fb
537+
*
538+
* Instead do: (A | B) - (A & B) in order to compute the XOR
533539
* of the two function addresses:
534540
*/
535-
. = ASSERT(((srso_untrain_ret_alias | srso_safe_ret_alias) -
536-
(srso_untrain_ret_alias & srso_safe_ret_alias)) == ((1 << 2) | (1 << 8) | (1 << 14) | (1 << 20)),
541+
. = ASSERT(((ABSOLUTE(srso_untrain_ret_alias) | srso_safe_ret_alias) -
542+
(ABSOLUTE(srso_untrain_ret_alias) & srso_safe_ret_alias)) == ((1 << 2) | (1 << 8) | (1 << 14) | (1 << 20)),
537543
"SRSO function pair won't alias");
538544
#endif
539545

arch/x86/kvm/x86.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ u64 __read_mostly host_xcr0;
314314

315315
static struct kmem_cache *x86_emulator_cache;
316316

317-
extern bool gds_ucode_mitigated(void);
318-
319317
/*
320318
* When called, it means the previous get/set msr reached an invalid msr.
321319
* Return true if we want to ignore/silent this failed msr access.

drivers/base/cpu.c

Lines changed: 19 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -509,85 +509,30 @@ static void __init cpu_dev_register_generic(void)
509509
}
510510

511511
#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
512-
513-
ssize_t __weak cpu_show_meltdown(struct device *dev,
514-
struct device_attribute *attr, char *buf)
515-
{
516-
return sysfs_emit(buf, "Not affected\n");
517-
}
518-
519-
ssize_t __weak cpu_show_spectre_v1(struct device *dev,
520-
struct device_attribute *attr, char *buf)
521-
{
522-
return sysfs_emit(buf, "Not affected\n");
523-
}
524-
525-
ssize_t __weak cpu_show_spectre_v2(struct device *dev,
526-
struct device_attribute *attr, char *buf)
527-
{
528-
return sysfs_emit(buf, "Not affected\n");
529-
}
530-
531-
ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
532-
struct device_attribute *attr, char *buf)
533-
{
534-
return sysfs_emit(buf, "Not affected\n");
535-
}
536-
537-
ssize_t __weak cpu_show_l1tf(struct device *dev,
538-
struct device_attribute *attr, char *buf)
539-
{
540-
return sysfs_emit(buf, "Not affected\n");
541-
}
542-
543-
ssize_t __weak cpu_show_mds(struct device *dev,
544-
struct device_attribute *attr, char *buf)
545-
{
546-
return sysfs_emit(buf, "Not affected\n");
547-
}
548-
549-
ssize_t __weak cpu_show_tsx_async_abort(struct device *dev,
550-
struct device_attribute *attr,
551-
char *buf)
552-
{
553-
return sysfs_emit(buf, "Not affected\n");
554-
}
555-
556-
ssize_t __weak cpu_show_itlb_multihit(struct device *dev,
557-
struct device_attribute *attr, char *buf)
558-
{
559-
return sysfs_emit(buf, "Not affected\n");
560-
}
561-
562-
ssize_t __weak cpu_show_srbds(struct device *dev,
512+
static ssize_t cpu_show_not_affected(struct device *dev,
563513
struct device_attribute *attr, char *buf)
564514
{
565515
return sysfs_emit(buf, "Not affected\n");
566516
}
567517

568-
ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
569-
struct device_attribute *attr, char *buf)
570-
{
571-
return sysfs_emit(buf, "Not affected\n");
572-
}
573-
574-
ssize_t __weak cpu_show_retbleed(struct device *dev,
575-
struct device_attribute *attr, char *buf)
576-
{
577-
return sysfs_emit(buf, "Not affected\n");
578-
}
579-
580-
ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
581-
struct device_attribute *attr, char *buf)
582-
{
583-
return sysfs_emit(buf, "Not affected\n");
584-
}
585-
586-
ssize_t __weak cpu_show_gds(struct device *dev,
587-
struct device_attribute *attr, char *buf)
588-
{
589-
return sysfs_emit(buf, "Not affected\n");
590-
}
518+
#define CPU_SHOW_VULN_FALLBACK(func) \
519+
ssize_t cpu_show_##func(struct device *, \
520+
struct device_attribute *, char *) \
521+
__attribute__((weak, alias("cpu_show_not_affected")))
522+
523+
CPU_SHOW_VULN_FALLBACK(meltdown);
524+
CPU_SHOW_VULN_FALLBACK(spectre_v1);
525+
CPU_SHOW_VULN_FALLBACK(spectre_v2);
526+
CPU_SHOW_VULN_FALLBACK(spec_store_bypass);
527+
CPU_SHOW_VULN_FALLBACK(l1tf);
528+
CPU_SHOW_VULN_FALLBACK(mds);
529+
CPU_SHOW_VULN_FALLBACK(tsx_async_abort);
530+
CPU_SHOW_VULN_FALLBACK(itlb_multihit);
531+
CPU_SHOW_VULN_FALLBACK(srbds);
532+
CPU_SHOW_VULN_FALLBACK(mmio_stale_data);
533+
CPU_SHOW_VULN_FALLBACK(retbleed);
534+
CPU_SHOW_VULN_FALLBACK(spec_rstack_overflow);
535+
CPU_SHOW_VULN_FALLBACK(gds);
591536

592537
static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
593538
static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);

include/linux/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ extern ssize_t cpu_show_retbleed(struct device *dev,
7272
struct device_attribute *attr, char *buf);
7373
extern ssize_t cpu_show_spec_rstack_overflow(struct device *dev,
7474
struct device_attribute *attr, char *buf);
75+
extern ssize_t cpu_show_gds(struct device *dev,
76+
struct device_attribute *attr, char *buf);
7577

7678
extern __printf(4, 5)
7779
struct device *cpu_device_create(struct device *parent, void *drvdata,

0 commit comments

Comments
 (0)