Skip to content

Commit 223cea6

Browse files
committed
Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 pti updates from Thomas Gleixner: "The speculative paranoia departement delivers a few more plugs for possible (probably theoretical) spectre/mds leaks" * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/tls: Fix possible spectre-v1 in do_get_thread_area() x86/ptrace: Fix possible spectre-v1 in ptrace_get_debugreg() x86/speculation/mds: Eliminate leaks by trace_hardirqs_on()
2 parents 2f0f650 + 993773d commit 223cea6

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

arch/x86/include/asm/mwait.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ static inline void __mwaitx(unsigned long eax, unsigned long ebx,
8686

8787
static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
8888
{
89-
mds_idle_clear_cpu_buffers();
90-
9189
trace_hardirqs_on();
90+
91+
mds_idle_clear_cpu_buffers();
9292
/* "mwait %eax, %ecx;" */
9393
asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
9494
:: "a" (eax), "c" (ecx));

arch/x86/kernel/ptrace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/rcupdate.h>
2626
#include <linux/export.h>
2727
#include <linux/context_tracking.h>
28+
#include <linux/nospec.h>
2829

2930
#include <linux/uaccess.h>
3031
#include <asm/pgtable.h>
@@ -635,7 +636,8 @@ static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
635636
unsigned long val = 0;
636637

637638
if (n < HBP_NUM) {
638-
struct perf_event *bp = thread->ptrace_bps[n];
639+
int index = array_index_nospec(n, HBP_NUM);
640+
struct perf_event *bp = thread->ptrace_bps[index];
639641

640642
if (bp)
641643
val = bp->hw.info.address;

arch/x86/kernel/tls.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/user.h>
66
#include <linux/regset.h>
77
#include <linux/syscalls.h>
8+
#include <linux/nospec.h>
89

910
#include <linux/uaccess.h>
1011
#include <asm/desc.h>
@@ -220,15 +221,19 @@ int do_get_thread_area(struct task_struct *p, int idx,
220221
struct user_desc __user *u_info)
221222
{
222223
struct user_desc info;
224+
int index;
223225

224226
if (idx == -1 && get_user(idx, &u_info->entry_number))
225227
return -EFAULT;
226228

227229
if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
228230
return -EINVAL;
229231

230-
fill_user_desc(&info, idx,
231-
&p->thread.tls_array[idx - GDT_ENTRY_TLS_MIN]);
232+
index = idx - GDT_ENTRY_TLS_MIN;
233+
index = array_index_nospec(index,
234+
GDT_ENTRY_TLS_MAX - GDT_ENTRY_TLS_MIN + 1);
235+
236+
fill_user_desc(&info, idx, &p->thread.tls_array[index]);
232237

233238
if (copy_to_user(u_info, &info, sizeof(info)))
234239
return -EFAULT;

0 commit comments

Comments
 (0)