Skip to content

Commit ed58d66

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: "Yet another pile of melted spectrum related updates: - Drop native vsyscall support finally as it causes more trouble than benefit. - Make microcode loading more robust. There were a few issues especially related to late loading which are now surfacing because late loading of the IB* microcodes addressing spectre issues has become more widely used. - Simplify and robustify the syscall handling in the entry code - Prevent kprobes on the entry trampoline code which lead to kernel crashes when the probe hits before CR3 is updated - Don't check microcode versions when running on hypervisors as they are considered as lying anyway. - Fix the 32bit objtool build and a coment typo" * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/kprobes: Fix kernel crash when probing .entry_trampoline code x86/pti: Fix a comment typo x86/microcode: Synchronize late microcode loading x86/microcode: Request microcode on the BSP x86/microcode/intel: Look into the patch cache first x86/microcode: Do not upload microcode if CPUs are offline x86/microcode/intel: Writeback and invalidate caches before updating microcode x86/microcode/intel: Check microcode revision before updating sibling threads x86/microcode: Get rid of struct apply_microcode_ctx x86/spectre_v2: Don't check microcode versions when running under hypervisors x86/vsyscall/64: Drop "native" vsyscalls x86/entry/64/compat: Save one instruction in entry_INT80_compat() x86/entry: Do not special-case clone(2) in compat entry x86/syscalls: Use COMPAT_SYSCALL_DEFINEx() macros for x86-only compat syscalls x86/syscalls: Use proper syscall definition for sys_ioperm() x86/entry: Remove stale syscall prototype x86/syscalls/32: Simplify $entry == $compat entries objtool: Fix 32-bit build
2 parents 1ad5daa + c07a8f8 commit ed58d66

File tree

17 files changed

+291
-182
lines changed

17 files changed

+291
-182
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,23 +2307,14 @@ choice
23072307
it can be used to assist security vulnerability exploitation.
23082308

23092309
This setting can be changed at boot time via the kernel command
2310-
line parameter vsyscall=[native|emulate|none].
2310+
line parameter vsyscall=[emulate|none].
23112311

23122312
On a system with recent enough glibc (2.14 or newer) and no
23132313
static binaries, you can say None without a performance penalty
23142314
to improve security.
23152315

23162316
If unsure, select "Emulate".
23172317

2318-
config LEGACY_VSYSCALL_NATIVE
2319-
bool "Native"
2320-
help
2321-
Actual executable code is located in the fixed vsyscall
2322-
address mapping, implementing time() efficiently. Since
2323-
this makes the mapping executable, it can be used during
2324-
security vulnerability exploitation (traditionally as
2325-
ROP gadgets). This configuration is not recommended.
2326-
23272318
config LEGACY_VSYSCALL_EMULATE
23282319
bool "Emulate"
23292320
help

arch/x86/entry/entry_64_compat.S

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,7 @@ ENTRY(entry_INT80_compat)
363363
pushq 2*8(%rdi) /* regs->ip */
364364
pushq 1*8(%rdi) /* regs->orig_ax */
365365

366-
movq (%rdi), %rdi /* restore %rdi */
367-
368-
pushq %rdi /* pt_regs->di */
366+
pushq (%rdi) /* pt_regs->di */
369367
pushq %rsi /* pt_regs->si */
370368
pushq %rdx /* pt_regs->dx */
371369
pushq %rcx /* pt_regs->cx */
@@ -406,15 +404,3 @@ ENTRY(entry_INT80_compat)
406404
TRACE_IRQS_ON
407405
jmp swapgs_restore_regs_and_return_to_usermode
408406
END(entry_INT80_compat)
409-
410-
ENTRY(stub32_clone)
411-
/*
412-
* The 32-bit clone ABI is: clone(..., int tls_val, int *child_tidptr).
413-
* The 64-bit clone ABI is: clone(..., int *child_tidptr, int tls_val).
414-
*
415-
* The native 64-bit kernel's sys_clone() implements the latter,
416-
* so we need to swap arguments here before calling it:
417-
*/
418-
xchg %r8, %rcx
419-
jmp sys_clone
420-
ENDPROC(stub32_clone)

arch/x86/entry/syscalls/syscall_32.tbl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
#
99
0 i386 restart_syscall sys_restart_syscall
1010
1 i386 exit sys_exit
11-
2 i386 fork sys_fork sys_fork
11+
2 i386 fork sys_fork
1212
3 i386 read sys_read
1313
4 i386 write sys_write
1414
5 i386 open sys_open compat_sys_open
1515
6 i386 close sys_close
16-
7 i386 waitpid sys_waitpid sys32_waitpid
16+
7 i386 waitpid sys_waitpid compat_sys_x86_waitpid
1717
8 i386 creat sys_creat
1818
9 i386 link sys_link
1919
10 i386 unlink sys_unlink
@@ -78,7 +78,7 @@
7878
69 i386 ssetmask sys_ssetmask
7979
70 i386 setreuid sys_setreuid16
8080
71 i386 setregid sys_setregid16
81-
72 i386 sigsuspend sys_sigsuspend sys_sigsuspend
81+
72 i386 sigsuspend sys_sigsuspend
8282
73 i386 sigpending sys_sigpending compat_sys_sigpending
8383
74 i386 sethostname sys_sethostname
8484
75 i386 setrlimit sys_setrlimit compat_sys_setrlimit
@@ -96,7 +96,7 @@
9696
87 i386 swapon sys_swapon
9797
88 i386 reboot sys_reboot
9898
89 i386 readdir sys_old_readdir compat_sys_old_readdir
99-
90 i386 mmap sys_old_mmap sys32_mmap
99+
90 i386 mmap sys_old_mmap compat_sys_x86_mmap
100100
91 i386 munmap sys_munmap
101101
92 i386 truncate sys_truncate compat_sys_truncate
102102
93 i386 ftruncate sys_ftruncate compat_sys_ftruncate
@@ -126,7 +126,7 @@
126126
117 i386 ipc sys_ipc compat_sys_ipc
127127
118 i386 fsync sys_fsync
128128
119 i386 sigreturn sys_sigreturn sys32_sigreturn
129-
120 i386 clone sys_clone stub32_clone
129+
120 i386 clone sys_clone compat_sys_x86_clone
130130
121 i386 setdomainname sys_setdomainname
131131
122 i386 uname sys_newuname
132132
123 i386 modify_ldt sys_modify_ldt
@@ -186,8 +186,8 @@
186186
177 i386 rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait
187187
178 i386 rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo
188188
179 i386 rt_sigsuspend sys_rt_sigsuspend
189-
180 i386 pread64 sys_pread64 sys32_pread
190-
181 i386 pwrite64 sys_pwrite64 sys32_pwrite
189+
180 i386 pread64 sys_pread64 compat_sys_x86_pread
190+
181 i386 pwrite64 sys_pwrite64 compat_sys_x86_pwrite
191191
182 i386 chown sys_chown16
192192
183 i386 getcwd sys_getcwd
193193
184 i386 capget sys_capget
@@ -196,14 +196,14 @@
196196
187 i386 sendfile sys_sendfile compat_sys_sendfile
197197
188 i386 getpmsg
198198
189 i386 putpmsg
199-
190 i386 vfork sys_vfork sys_vfork
199+
190 i386 vfork sys_vfork
200200
191 i386 ugetrlimit sys_getrlimit compat_sys_getrlimit
201201
192 i386 mmap2 sys_mmap_pgoff
202-
193 i386 truncate64 sys_truncate64 sys32_truncate64
203-
194 i386 ftruncate64 sys_ftruncate64 sys32_ftruncate64
204-
195 i386 stat64 sys_stat64 sys32_stat64
205-
196 i386 lstat64 sys_lstat64 sys32_lstat64
206-
197 i386 fstat64 sys_fstat64 sys32_fstat64
202+
193 i386 truncate64 sys_truncate64 compat_sys_x86_truncate64
203+
194 i386 ftruncate64 sys_ftruncate64 compat_sys_x86_ftruncate64
204+
195 i386 stat64 sys_stat64 compat_sys_x86_stat64
205+
196 i386 lstat64 sys_lstat64 compat_sys_x86_lstat64
206+
197 i386 fstat64 sys_fstat64 compat_sys_x86_fstat64
207207
198 i386 lchown32 sys_lchown
208208
199 i386 getuid32 sys_getuid
209209
200 i386 getgid32 sys_getgid
@@ -231,7 +231,7 @@
231231
# 222 is unused
232232
# 223 is unused
233233
224 i386 gettid sys_gettid
234-
225 i386 readahead sys_readahead sys32_readahead
234+
225 i386 readahead sys_readahead compat_sys_x86_readahead
235235
226 i386 setxattr sys_setxattr
236236
227 i386 lsetxattr sys_lsetxattr
237237
228 i386 fsetxattr sys_fsetxattr
@@ -256,7 +256,7 @@
256256
247 i386 io_getevents sys_io_getevents compat_sys_io_getevents
257257
248 i386 io_submit sys_io_submit compat_sys_io_submit
258258
249 i386 io_cancel sys_io_cancel
259-
250 i386 fadvise64 sys_fadvise64 sys32_fadvise64
259+
250 i386 fadvise64 sys_fadvise64 compat_sys_x86_fadvise64
260260
# 251 is available for reuse (was briefly sys_set_zone_reclaim)
261261
252 i386 exit_group sys_exit_group
262262
253 i386 lookup_dcookie sys_lookup_dcookie compat_sys_lookup_dcookie
@@ -278,7 +278,7 @@
278278
269 i386 fstatfs64 sys_fstatfs64 compat_sys_fstatfs64
279279
270 i386 tgkill sys_tgkill
280280
271 i386 utimes sys_utimes compat_sys_utimes
281-
272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
281+
272 i386 fadvise64_64 sys_fadvise64_64 compat_sys_x86_fadvise64_64
282282
273 i386 vserver
283283
274 i386 mbind sys_mbind
284284
275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
@@ -306,7 +306,7 @@
306306
297 i386 mknodat sys_mknodat
307307
298 i386 fchownat sys_fchownat
308308
299 i386 futimesat sys_futimesat compat_sys_futimesat
309-
300 i386 fstatat64 sys_fstatat64 sys32_fstatat
309+
300 i386 fstatat64 sys_fstatat64 compat_sys_x86_fstatat
310310
301 i386 unlinkat sys_unlinkat
311311
302 i386 renameat sys_renameat
312312
303 i386 linkat sys_linkat
@@ -320,7 +320,7 @@
320320
311 i386 set_robust_list sys_set_robust_list compat_sys_set_robust_list
321321
312 i386 get_robust_list sys_get_robust_list compat_sys_get_robust_list
322322
313 i386 splice sys_splice
323-
314 i386 sync_file_range sys_sync_file_range sys32_sync_file_range
323+
314 i386 sync_file_range sys_sync_file_range compat_sys_x86_sync_file_range
324324
315 i386 tee sys_tee
325325
316 i386 vmsplice sys_vmsplice compat_sys_vmsplice
326326
317 i386 move_pages sys_move_pages compat_sys_move_pages
@@ -330,7 +330,7 @@
330330
321 i386 signalfd sys_signalfd compat_sys_signalfd
331331
322 i386 timerfd_create sys_timerfd_create
332332
323 i386 eventfd sys_eventfd
333-
324 i386 fallocate sys_fallocate sys32_fallocate
333+
324 i386 fallocate sys_fallocate compat_sys_x86_fallocate
334334
325 i386 timerfd_settime sys_timerfd_settime compat_sys_timerfd_settime
335335
326 i386 timerfd_gettime sys_timerfd_gettime compat_sys_timerfd_gettime
336336
327 i386 signalfd4 sys_signalfd4 compat_sys_signalfd4

arch/x86/entry/vsyscall/vsyscall_64.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@
4242
#define CREATE_TRACE_POINTS
4343
#include "vsyscall_trace.h"
4444

45-
static enum { EMULATE, NATIVE, NONE } vsyscall_mode =
46-
#if defined(CONFIG_LEGACY_VSYSCALL_NATIVE)
47-
NATIVE;
48-
#elif defined(CONFIG_LEGACY_VSYSCALL_NONE)
45+
static enum { EMULATE, NONE } vsyscall_mode =
46+
#ifdef CONFIG_LEGACY_VSYSCALL_NONE
4947
NONE;
5048
#else
5149
EMULATE;
@@ -56,8 +54,6 @@ static int __init vsyscall_setup(char *str)
5654
if (str) {
5755
if (!strcmp("emulate", str))
5856
vsyscall_mode = EMULATE;
59-
else if (!strcmp("native", str))
60-
vsyscall_mode = NATIVE;
6157
else if (!strcmp("none", str))
6258
vsyscall_mode = NONE;
6359
else
@@ -139,10 +135,6 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
139135

140136
WARN_ON_ONCE(address != regs->ip);
141137

142-
/* This should be unreachable in NATIVE mode. */
143-
if (WARN_ON(vsyscall_mode == NATIVE))
144-
return false;
145-
146138
if (vsyscall_mode == NONE) {
147139
warn_bad_vsyscall(KERN_INFO, regs,
148140
"vsyscall attempted with vsyscall=none");
@@ -370,9 +362,7 @@ void __init map_vsyscall(void)
370362

371363
if (vsyscall_mode != NONE) {
372364
__set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall,
373-
vsyscall_mode == NATIVE
374-
? PAGE_KERNEL_VSYSCALL
375-
: PAGE_KERNEL_VVAR);
365+
PAGE_KERNEL_VVAR);
376366
set_vsyscall_pgtable_user_bits(swapper_pg_dir);
377367
}
378368

arch/x86/ia32/sys_ia32.c

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@
5151
#define AA(__x) ((unsigned long)(__x))
5252

5353

54-
asmlinkage long sys32_truncate64(const char __user *filename,
55-
unsigned long offset_low,
56-
unsigned long offset_high)
54+
COMPAT_SYSCALL_DEFINE3(x86_truncate64, const char __user *, filename,
55+
unsigned long, offset_low, unsigned long, offset_high)
5756
{
5857
return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
5958
}
6059

61-
asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
62-
unsigned long offset_high)
60+
COMPAT_SYSCALL_DEFINE3(x86_ftruncate64, unsigned int, fd,
61+
unsigned long, offset_low, unsigned long, offset_high)
6362
{
6463
return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
6564
}
@@ -96,8 +95,8 @@ static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
9695
return 0;
9796
}
9897

99-
asmlinkage long sys32_stat64(const char __user *filename,
100-
struct stat64 __user *statbuf)
98+
COMPAT_SYSCALL_DEFINE2(x86_stat64, const char __user *, filename,
99+
struct stat64 __user *, statbuf)
101100
{
102101
struct kstat stat;
103102
int ret = vfs_stat(filename, &stat);
@@ -107,8 +106,8 @@ asmlinkage long sys32_stat64(const char __user *filename,
107106
return ret;
108107
}
109108

110-
asmlinkage long sys32_lstat64(const char __user *filename,
111-
struct stat64 __user *statbuf)
109+
COMPAT_SYSCALL_DEFINE2(x86_lstat64, const char __user *, filename,
110+
struct stat64 __user *, statbuf)
112111
{
113112
struct kstat stat;
114113
int ret = vfs_lstat(filename, &stat);
@@ -117,7 +116,8 @@ asmlinkage long sys32_lstat64(const char __user *filename,
117116
return ret;
118117
}
119118

120-
asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
119+
COMPAT_SYSCALL_DEFINE2(x86_fstat64, unsigned int, fd,
120+
struct stat64 __user *, statbuf)
121121
{
122122
struct kstat stat;
123123
int ret = vfs_fstat(fd, &stat);
@@ -126,8 +126,9 @@ asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
126126
return ret;
127127
}
128128

129-
asmlinkage long sys32_fstatat(unsigned int dfd, const char __user *filename,
130-
struct stat64 __user *statbuf, int flag)
129+
COMPAT_SYSCALL_DEFINE4(x86_fstatat, unsigned int, dfd,
130+
const char __user *, filename,
131+
struct stat64 __user *, statbuf, int, flag)
131132
{
132133
struct kstat stat;
133134
int error;
@@ -153,7 +154,7 @@ struct mmap_arg_struct32 {
153154
unsigned int offset;
154155
};
155156

156-
asmlinkage long sys32_mmap(struct mmap_arg_struct32 __user *arg)
157+
COMPAT_SYSCALL_DEFINE1(x86_mmap, struct mmap_arg_struct32 __user *, arg)
157158
{
158159
struct mmap_arg_struct32 a;
159160

@@ -167,22 +168,22 @@ asmlinkage long sys32_mmap(struct mmap_arg_struct32 __user *arg)
167168
a.offset>>PAGE_SHIFT);
168169
}
169170

170-
asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int __user *stat_addr,
171-
int options)
171+
COMPAT_SYSCALL_DEFINE3(x86_waitpid, compat_pid_t, pid, unsigned int __user *,
172+
stat_addr, int, options)
172173
{
173174
return compat_sys_wait4(pid, stat_addr, options, NULL);
174175
}
175176

176177
/* warning: next two assume little endian */
177-
asmlinkage long sys32_pread(unsigned int fd, char __user *ubuf, u32 count,
178-
u32 poslo, u32 poshi)
178+
COMPAT_SYSCALL_DEFINE5(x86_pread, unsigned int, fd, char __user *, ubuf,
179+
u32, count, u32, poslo, u32, poshi)
179180
{
180181
return sys_pread64(fd, ubuf, count,
181182
((loff_t)AA(poshi) << 32) | AA(poslo));
182183
}
183184

184-
asmlinkage long sys32_pwrite(unsigned int fd, const char __user *ubuf,
185-
u32 count, u32 poslo, u32 poshi)
185+
COMPAT_SYSCALL_DEFINE5(x86_pwrite, unsigned int, fd, const char __user *, ubuf,
186+
u32, count, u32, poslo, u32, poshi)
186187
{
187188
return sys_pwrite64(fd, ubuf, count,
188189
((loff_t)AA(poshi) << 32) | AA(poslo));
@@ -193,40 +194,53 @@ asmlinkage long sys32_pwrite(unsigned int fd, const char __user *ubuf,
193194
* Some system calls that need sign extended arguments. This could be
194195
* done by a generic wrapper.
195196
*/
196-
long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
197-
__u32 len_low, __u32 len_high, int advice)
197+
COMPAT_SYSCALL_DEFINE6(x86_fadvise64_64, int, fd, __u32, offset_low,
198+
__u32, offset_high, __u32, len_low, __u32, len_high,
199+
int, advice)
198200
{
199201
return sys_fadvise64_64(fd,
200202
(((u64)offset_high)<<32) | offset_low,
201203
(((u64)len_high)<<32) | len_low,
202204
advice);
203205
}
204206

205-
asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,
206-
size_t count)
207+
COMPAT_SYSCALL_DEFINE4(x86_readahead, int, fd, unsigned int, off_lo,
208+
unsigned int, off_hi, size_t, count)
207209
{
208210
return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
209211
}
210212

211-
asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
212-
unsigned n_low, unsigned n_hi, int flags)
213+
COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low,
214+
unsigned int, off_hi, unsigned int, n_low,
215+
unsigned int, n_hi, int, flags)
213216
{
214217
return sys_sync_file_range(fd,
215218
((u64)off_hi << 32) | off_low,
216219
((u64)n_hi << 32) | n_low, flags);
217220
}
218221

219-
asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
220-
size_t len, int advice)
222+
COMPAT_SYSCALL_DEFINE5(x86_fadvise64, int, fd, unsigned int, offset_lo,
223+
unsigned int, offset_hi, size_t, len, int, advice)
221224
{
222225
return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
223226
len, advice);
224227
}
225228

226-
asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
227-
unsigned offset_hi, unsigned len_lo,
228-
unsigned len_hi)
229+
COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode,
230+
unsigned int, offset_lo, unsigned int, offset_hi,
231+
unsigned int, len_lo, unsigned int, len_hi)
229232
{
230233
return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
231234
((u64)len_hi << 32) | len_lo);
232235
}
236+
237+
/*
238+
* The 32-bit clone ABI is CONFIG_CLONE_BACKWARDS
239+
*/
240+
COMPAT_SYSCALL_DEFINE5(x86_clone, unsigned long, clone_flags,
241+
unsigned long, newsp, int __user *, parent_tidptr,
242+
unsigned long, tls_val, int __user *, child_tidptr)
243+
{
244+
return sys_clone(clone_flags, newsp, parent_tidptr, child_tidptr,
245+
tls_val);
246+
}

0 commit comments

Comments
 (0)