Skip to content

Commit 629e3cf

Browse files
committed
Merge remote-tracking branch 'stable/linux-4.14.y' into rpi-4.14.y
2 parents ec05b1a + 1dff084 commit 629e3cf

83 files changed

Lines changed: 1556 additions & 311 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎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 <linux-kernel@vger.kernel.org>
383384
Description: Information about CPU vulnerabilities

‎Documentation/admin-guide/kernel-parameters.txt‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,9 @@
26002600
allow data leaks with this option, which is equivalent
26012601
to spectre_v2=off.
26022602

2603+
nospec_store_bypass_disable
2604+
[HW] Disable all mitigations for the Speculative Store Bypass vulnerability
2605+
26032606
noxsave [BUGS=X86] Disables x86 extended register state save
26042607
and restore using xsave. The kernel will fallback to
26052608
enabling legacy floating-point and sse state.
@@ -3930,6 +3933,48 @@
39303933
Not specifying this option is equivalent to
39313934
spectre_v2=auto.
39323935

3936+
spec_store_bypass_disable=
3937+
[HW] Control Speculative Store Bypass (SSB) Disable mitigation
3938+
(Speculative Store Bypass vulnerability)
3939+
3940+
Certain CPUs are vulnerable to an exploit against a
3941+
a common industry wide performance optimization known
3942+
as "Speculative Store Bypass" in which recent stores
3943+
to the same memory location may not be observed by
3944+
later loads during speculative execution. The idea
3945+
is that such stores are unlikely and that they can
3946+
be detected prior to instruction retirement at the
3947+
end of a particular speculation execution window.
3948+
3949+
In vulnerable processors, the speculatively forwarded
3950+
store can be used in a cache side channel attack, for
3951+
example to read memory to which the attacker does not
3952+
directly have access (e.g. inside sandboxed code).
3953+
3954+
This parameter controls whether the Speculative Store
3955+
Bypass optimization is used.
3956+
3957+
on - Unconditionally disable Speculative Store Bypass
3958+
off - Unconditionally enable Speculative Store Bypass
3959+
auto - Kernel detects whether the CPU model contains an
3960+
implementation of Speculative Store Bypass and
3961+
picks the most appropriate mitigation. If the
3962+
CPU is not vulnerable, "off" is selected. If the
3963+
CPU is vulnerable the default mitigation is
3964+
architecture and Kconfig dependent. See below.
3965+
prctl - Control Speculative Store Bypass per thread
3966+
via prctl. Speculative Store Bypass is enabled
3967+
for a process by default. The state of the control
3968+
is inherited on fork.
3969+
seccomp - Same as "prctl" above, but all seccomp threads
3970+
will disable SSB unless they explicitly opt out.
3971+
3972+
Not specifying this option is equivalent to
3973+
spec_store_bypass_disable=auto.
3974+
3975+
Default mitigations:
3976+
X86: If CONFIG_SECCOMP=y "seccomp", otherwise "prctl"
3977+
39333978
spia_io_base= [HW,MTD]
39343979
spia_fio_base=
39353980
spia_pedr=

‎Documentation/userspace-api/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ place where this information is gathered.
1919
no_new_privs
2020
seccomp_filter
2121
unshare
22+
spec_ctrl
2223

2324
.. only:: subproject and html
2425

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
===================
2+
Speculation Control
3+
===================
4+
5+
Quite some CPUs have speculation-related misfeatures which are in
6+
fact vulnerabilities causing data leaks in various forms even across
7+
privilege domains.
8+
9+
The kernel provides mitigation for such vulnerabilities in various
10+
forms. Some of these mitigations are compile-time configurable and some
11+
can be supplied on the kernel command line.
12+
13+
There is also a class of mitigations which are very expensive, but they can
14+
be restricted to a certain set of processes or tasks in controlled
15+
environments. The mechanism to control these mitigations is via
16+
:manpage:`prctl(2)`.
17+
18+
There are two prctl options which are related to this:
19+
20+
* PR_GET_SPECULATION_CTRL
21+
22+
* PR_SET_SPECULATION_CTRL
23+
24+
PR_GET_SPECULATION_CTRL
25+
-----------------------
26+
27+
PR_GET_SPECULATION_CTRL returns the state of the speculation misfeature
28+
which is selected with arg2 of prctl(2). The return value uses bits 0-3 with
29+
the following meaning:
30+
31+
==== ===================== ===================================================
32+
Bit Define Description
33+
==== ===================== ===================================================
34+
0 PR_SPEC_PRCTL Mitigation can be controlled per task by
35+
PR_SET_SPECULATION_CTRL.
36+
1 PR_SPEC_ENABLE The speculation feature is enabled, mitigation is
37+
disabled.
38+
2 PR_SPEC_DISABLE The speculation feature is disabled, mitigation is
39+
enabled.
40+
3 PR_SPEC_FORCE_DISABLE Same as PR_SPEC_DISABLE, but cannot be undone. A
41+
subsequent prctl(..., PR_SPEC_ENABLE) will fail.
42+
==== ===================== ===================================================
43+
44+
If all bits are 0 the CPU is not affected by the speculation misfeature.
45+
46+
If PR_SPEC_PRCTL is set, then the per-task control of the mitigation is
47+
available. If not set, prctl(PR_SET_SPECULATION_CTRL) for the speculation
48+
misfeature will fail.
49+
50+
PR_SET_SPECULATION_CTRL
51+
-----------------------
52+
53+
PR_SET_SPECULATION_CTRL allows to control the speculation misfeature, which
54+
is selected by arg2 of :manpage:`prctl(2)` per task. arg3 is used to hand
55+
in the control value, i.e. either PR_SPEC_ENABLE or PR_SPEC_DISABLE or
56+
PR_SPEC_FORCE_DISABLE.
57+
58+
Common error codes
59+
------------------
60+
======= =================================================================
61+
Value Meaning
62+
======= =================================================================
63+
EINVAL The prctl is not implemented by the architecture or unused
64+
prctl(2) arguments are not 0.
65+
66+
ENODEV arg2 is selecting a not supported speculation misfeature.
67+
======= =================================================================
68+
69+
PR_SET_SPECULATION_CTRL error codes
70+
-----------------------------------
71+
======= =================================================================
72+
Value Meaning
73+
======= =================================================================
74+
0 Success
75+
76+
ERANGE arg3 is incorrect, i.e. it's neither PR_SPEC_ENABLE nor
77+
PR_SPEC_DISABLE nor PR_SPEC_FORCE_DISABLE.
78+
79+
ENXIO Control of the selected speculation misfeature is not possible.
80+
See PR_GET_SPECULATION_CTRL.
81+
82+
EPERM Speculation was disabled with PR_SPEC_FORCE_DISABLE and caller
83+
tried to enable it again.
84+
======= =================================================================
85+
86+
Speculation misfeature controls
87+
-------------------------------
88+
- PR_SPEC_STORE_BYPASS: Speculative Store Bypass
89+
90+
Invocations:
91+
* prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, 0, 0, 0);
92+
* prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_ENABLE, 0, 0);
93+
* prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
94+
* prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_FORCE_DISABLE, 0, 0);

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 4
33
PATCHLEVEL = 14
4-
SUBLEVEL = 42
4+
SUBLEVEL = 43
55
EXTRAVERSION =
66
NAME = Petit Gorille
77

‎arch/arm/include/asm/assembler.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,4 +536,14 @@ THUMB( orr \reg , \reg , #PSR_T_BIT )
536536
#endif
537537
.endm
538538

539+
#ifdef CONFIG_KPROBES
540+
#define _ASM_NOKPROBE(entry) \
541+
.pushsection "_kprobe_blacklist", "aw" ; \
542+
.balign 4 ; \
543+
.long entry; \
544+
.popsection
545+
#else
546+
#define _ASM_NOKPROBE(entry)
547+
#endif
548+
539549
#endif /* __ASM_ASSEMBLER_H__ */

‎arch/arm/include/asm/kvm_mmu.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,22 @@ static inline unsigned int kvm_get_vmid_bits(void)
221221
return 8;
222222
}
223223

224+
/*
225+
* We are not in the kvm->srcu critical section most of the time, so we take
226+
* the SRCU read lock here. Since we copy the data from the user page, we
227+
* can immediately drop the lock again.
228+
*/
229+
static inline int kvm_read_guest_lock(struct kvm *kvm,
230+
gpa_t gpa, void *data, unsigned long len)
231+
{
232+
int srcu_idx = srcu_read_lock(&kvm->srcu);
233+
int ret = kvm_read_guest(kvm, gpa, data, len);
234+
235+
srcu_read_unlock(&kvm->srcu, srcu_idx);
236+
237+
return ret;
238+
}
239+
224240
static inline void *kvm_get_hyp_vector(void)
225241
{
226242
return kvm_ksym_ref(__kvm_hyp_vector);

‎arch/arm/kernel/traps.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/uaccess.h>
2020
#include <linux/hardirq.h>
2121
#include <linux/kdebug.h>
22+
#include <linux/kprobes.h>
2223
#include <linux/module.h>
2324
#include <linux/kexec.h>
2425
#include <linux/bug.h>
@@ -417,7 +418,8 @@ void unregister_undef_hook(struct undef_hook *hook)
417418
raw_spin_unlock_irqrestore(&undef_lock, flags);
418419
}
419420

420-
static int call_undef_hook(struct pt_regs *regs, unsigned int instr)
421+
static nokprobe_inline
422+
int call_undef_hook(struct pt_regs *regs, unsigned int instr)
421423
{
422424
struct undef_hook *hook;
423425
unsigned long flags;
@@ -490,6 +492,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
490492

491493
arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6);
492494
}
495+
NOKPROBE_SYMBOL(do_undefinstr)
493496

494497
/*
495498
* Handle FIQ similarly to NMI on x86 systems.

‎arch/arm/lib/getuser.S‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ ENTRY(__get_user_1)
3838
mov r0, #0
3939
ret lr
4040
ENDPROC(__get_user_1)
41+
_ASM_NOKPROBE(__get_user_1)
4142

4243
ENTRY(__get_user_2)
4344
check_uaccess r0, 2, r1, r2, __get_user_bad
@@ -58,13 +59,15 @@ rb .req r0
5859
mov r0, #0
5960
ret lr
6061
ENDPROC(__get_user_2)
62+
_ASM_NOKPROBE(__get_user_2)
6163

6264
ENTRY(__get_user_4)
6365
check_uaccess r0, 4, r1, r2, __get_user_bad
6466
4: TUSER(ldr) r2, [r0]
6567
mov r0, #0
6668
ret lr
6769
ENDPROC(__get_user_4)
70+
_ASM_NOKPROBE(__get_user_4)
6871

6972
ENTRY(__get_user_8)
7073
check_uaccess r0, 8, r1, r2, __get_user_bad8
@@ -78,6 +81,7 @@ ENTRY(__get_user_8)
7881
mov r0, #0
7982
ret lr
8083
ENDPROC(__get_user_8)
84+
_ASM_NOKPROBE(__get_user_8)
8185

8286
#ifdef __ARMEB__
8387
ENTRY(__get_user_32t_8)
@@ -91,13 +95,15 @@ ENTRY(__get_user_32t_8)
9195
mov r0, #0
9296
ret lr
9397
ENDPROC(__get_user_32t_8)
98+
_ASM_NOKPROBE(__get_user_32t_8)
9499

95100
ENTRY(__get_user_64t_1)
96101
check_uaccess r0, 1, r1, r2, __get_user_bad8
97102
8: TUSER(ldrb) r3, [r0]
98103
mov r0, #0
99104
ret lr
100105
ENDPROC(__get_user_64t_1)
106+
_ASM_NOKPROBE(__get_user_64t_1)
101107

102108
ENTRY(__get_user_64t_2)
103109
check_uaccess r0, 2, r1, r2, __get_user_bad8
@@ -114,13 +120,15 @@ rb .req r0
114120
mov r0, #0
115121
ret lr
116122
ENDPROC(__get_user_64t_2)
123+
_ASM_NOKPROBE(__get_user_64t_2)
117124

118125
ENTRY(__get_user_64t_4)
119126
check_uaccess r0, 4, r1, r2, __get_user_bad8
120127
11: TUSER(ldr) r3, [r0]
121128
mov r0, #0
122129
ret lr
123130
ENDPROC(__get_user_64t_4)
131+
_ASM_NOKPROBE(__get_user_64t_4)
124132
#endif
125133

126134
__get_user_bad8:
@@ -131,6 +139,8 @@ __get_user_bad:
131139
ret lr
132140
ENDPROC(__get_user_bad)
133141
ENDPROC(__get_user_bad8)
142+
_ASM_NOKPROBE(__get_user_bad)
143+
_ASM_NOKPROBE(__get_user_bad8)
134144

135145
.pushsection __ex_table, "a"
136146
.long 1b, __get_user_bad

‎arch/arm/probes/kprobes/opt-arm.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,14 @@ optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
165165
{
166166
unsigned long flags;
167167
struct kprobe *p = &op->kp;
168-
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
168+
struct kprobe_ctlblk *kcb;
169169

170170
/* Save skipped registers */
171171
regs->ARM_pc = (unsigned long)op->kp.addr;
172172
regs->ARM_ORIG_r0 = ~0UL;
173173

174174
local_irq_save(flags);
175+
kcb = get_kprobe_ctlblk();
175176

176177
if (kprobe_running()) {
177178
kprobes_inc_nmissed_count(&op->kp);
@@ -191,6 +192,7 @@ optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
191192

192193
local_irq_restore(flags);
193194
}
195+
NOKPROBE_SYMBOL(optimized_callback)
194196

195197
int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *orig)
196198
{

0 commit comments

Comments
 (0)