Skip to content

Commit e6023ad

Browse files
committed
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull core fixes from Thomas Gleixner: - A collection of objtool fixes which address recent fallout partially exposed by newer toolchains, clang, BPF and general code changes. - Force USER_DS for user stack traces [ Note: the "objtool fixes" are not all to objtool itself, but for kernel code that triggers objtool warnings. Things like missing function size annotations, or code that confuses the unwinder etc. - Linus] * 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (27 commits) objtool: Support conditional retpolines objtool: Convert insn type to enum objtool: Fix seg fault on bad switch table entry objtool: Support repeated uses of the same C jump table objtool: Refactor jump table code objtool: Refactor sibling call detection logic objtool: Do frame pointer check before dead end check objtool: Change dead_end_function() to return boolean objtool: Warn on zero-length functions objtool: Refactor function alias logic objtool: Track original function across branches objtool: Add mcsafe_handle_tail() to the uaccess safe list bpf: Disable GCC -fgcse optimization for ___bpf_prog_run() x86/uaccess: Remove redundant CLACs in getuser/putuser error paths x86/uaccess: Don't leak AC flag into fentry from mcsafe_handle_tail() x86/uaccess: Remove ELF function annotation from copy_user_handle_tail() x86/head/64: Annotate start_cpu0() as non-callable x86/entry: Fix thunk function ELF sizes x86/kvm: Don't call kvm_spurious_fault() from .fixup x86/kvm: Replace vmx_vmenter()'s call to kvm_spurious_fault() with UD2 ...
2 parents 4b01f5a + b68b990 commit e6023ad

File tree

22 files changed

+311
-245
lines changed

22 files changed

+311
-245
lines changed

arch/x86/entry/thunk_64.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313
/* rdi: arg1 ... normal C conventions. rax is saved/restored. */
1414
.macro THUNK name, func, put_ret_addr_in_rdi=0
15-
.globl \name
16-
.type \name, @function
17-
\name:
15+
ENTRY(\name)
1816
pushq %rbp
1917
movq %rsp, %rbp
2018

@@ -35,6 +33,7 @@
3533

3634
call \func
3735
jmp .L_restore
36+
ENDPROC(\name)
3837
_ASM_NOKPROBE(\name)
3938
.endm
4039

arch/x86/include/asm/kvm_host.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,25 +1496,29 @@ enum {
14961496
#define kvm_arch_vcpu_memslots_id(vcpu) ((vcpu)->arch.hflags & HF_SMM_MASK ? 1 : 0)
14971497
#define kvm_memslots_for_spte_role(kvm, role) __kvm_memslots(kvm, (role).smm)
14981498

1499+
asmlinkage void __noreturn kvm_spurious_fault(void);
1500+
14991501
/*
15001502
* Hardware virtualization extension instructions may fault if a
15011503
* reboot turns off virtualization while processes are running.
1502-
* Trap the fault and ignore the instruction if that happens.
1504+
* Usually after catching the fault we just panic; during reboot
1505+
* instead the instruction is ignored.
15031506
*/
1504-
asmlinkage void kvm_spurious_fault(void);
1505-
1506-
#define ____kvm_handle_fault_on_reboot(insn, cleanup_insn) \
1507-
"666: " insn "\n\t" \
1508-
"668: \n\t" \
1509-
".pushsection .fixup, \"ax\" \n" \
1510-
"667: \n\t" \
1511-
cleanup_insn "\n\t" \
1512-
"cmpb $0, kvm_rebooting \n\t" \
1513-
"jne 668b \n\t" \
1514-
__ASM_SIZE(push) " $666b \n\t" \
1515-
"jmp kvm_spurious_fault \n\t" \
1516-
".popsection \n\t" \
1517-
_ASM_EXTABLE(666b, 667b)
1507+
#define ____kvm_handle_fault_on_reboot(insn, cleanup_insn) \
1508+
"666: \n\t" \
1509+
insn "\n\t" \
1510+
"jmp 668f \n\t" \
1511+
"667: \n\t" \
1512+
"call kvm_spurious_fault \n\t" \
1513+
"668: \n\t" \
1514+
".pushsection .fixup, \"ax\" \n\t" \
1515+
"700: \n\t" \
1516+
cleanup_insn "\n\t" \
1517+
"cmpb $0, kvm_rebooting\n\t" \
1518+
"je 667b \n\t" \
1519+
"jmp 668b \n\t" \
1520+
".popsection \n\t" \
1521+
_ASM_EXTABLE(666b, 700b)
15181522

15191523
#define __kvm_handle_fault_on_reboot(insn) \
15201524
____kvm_handle_fault_on_reboot(insn, "")

arch/x86/include/asm/paravirt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
746746
PV_RESTORE_ALL_CALLER_REGS \
747747
FRAME_END \
748748
"ret;" \
749+
".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
749750
".popsection")
750751

751752
/* Get a reference to a callee-save function */

arch/x86/kernel/head_64.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ END(secondary_startup_64)
253253
* start_secondary() via .Ljump_to_C_code.
254254
*/
255255
ENTRY(start_cpu0)
256-
movq initial_stack(%rip), %rsp
257256
UNWIND_HINT_EMPTY
257+
movq initial_stack(%rip), %rsp
258258
jmp .Ljump_to_C_code
259-
ENDPROC(start_cpu0)
259+
END(start_cpu0)
260260
#endif
261261

262262
/* Both SMP bootup and ACPI suspend change these variables */

arch/x86/kernel/kvm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ asm(
838838
"cmpb $0, " __stringify(KVM_STEAL_TIME_preempted) "+steal_time(%rax);"
839839
"setne %al;"
840840
"ret;"
841+
".size __raw_callee_save___kvm_vcpu_is_preempted, .-__raw_callee_save___kvm_vcpu_is_preempted;"
841842
".popsection");
842843

843844
#endif

arch/x86/kvm/emulate.c

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,29 +312,42 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
312312

313313
static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
314314

315-
#define FOP_FUNC(name) \
315+
#define __FOP_FUNC(name) \
316316
".align " __stringify(FASTOP_SIZE) " \n\t" \
317317
".type " name ", @function \n\t" \
318318
name ":\n\t"
319319

320-
#define FOP_RET "ret \n\t"
320+
#define FOP_FUNC(name) \
321+
__FOP_FUNC(#name)
322+
323+
#define __FOP_RET(name) \
324+
"ret \n\t" \
325+
".size " name ", .-" name "\n\t"
326+
327+
#define FOP_RET(name) \
328+
__FOP_RET(#name)
321329

322330
#define FOP_START(op) \
323331
extern void em_##op(struct fastop *fake); \
324332
asm(".pushsection .text, \"ax\" \n\t" \
325333
".global em_" #op " \n\t" \
326-
FOP_FUNC("em_" #op)
334+
".align " __stringify(FASTOP_SIZE) " \n\t" \
335+
"em_" #op ":\n\t"
327336

328337
#define FOP_END \
329338
".popsection")
330339

340+
#define __FOPNOP(name) \
341+
__FOP_FUNC(name) \
342+
__FOP_RET(name)
343+
331344
#define FOPNOP() \
332-
FOP_FUNC(__stringify(__UNIQUE_ID(nop))) \
333-
FOP_RET
345+
__FOPNOP(__stringify(__UNIQUE_ID(nop)))
334346

335347
#define FOP1E(op, dst) \
336-
FOP_FUNC(#op "_" #dst) \
337-
"10: " #op " %" #dst " \n\t" FOP_RET
348+
__FOP_FUNC(#op "_" #dst) \
349+
"10: " #op " %" #dst " \n\t" \
350+
__FOP_RET(#op "_" #dst)
338351

339352
#define FOP1EEX(op, dst) \
340353
FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception)
@@ -366,8 +379,9 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
366379
FOP_END
367380

368381
#define FOP2E(op, dst, src) \
369-
FOP_FUNC(#op "_" #dst "_" #src) \
370-
#op " %" #src ", %" #dst " \n\t" FOP_RET
382+
__FOP_FUNC(#op "_" #dst "_" #src) \
383+
#op " %" #src ", %" #dst " \n\t" \
384+
__FOP_RET(#op "_" #dst "_" #src)
371385

372386
#define FASTOP2(op) \
373387
FOP_START(op) \
@@ -405,8 +419,9 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
405419
FOP_END
406420

407421
#define FOP3E(op, dst, src, src2) \
408-
FOP_FUNC(#op "_" #dst "_" #src "_" #src2) \
409-
#op " %" #src2 ", %" #src ", %" #dst " \n\t" FOP_RET
422+
__FOP_FUNC(#op "_" #dst "_" #src "_" #src2) \
423+
#op " %" #src2 ", %" #src ", %" #dst " \n\t"\
424+
__FOP_RET(#op "_" #dst "_" #src "_" #src2)
410425

411426
/* 3-operand, word-only, src2=cl */
412427
#define FASTOP3WCL(op) \
@@ -423,7 +438,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
423438
".type " #op ", @function \n\t" \
424439
#op ": \n\t" \
425440
#op " %al \n\t" \
426-
FOP_RET
441+
__FOP_RET(#op)
427442

428443
asm(".pushsection .fixup, \"ax\"\n"
429444
".global kvm_fastop_exception \n"
@@ -449,7 +464,10 @@ FOP_SETCC(setle)
449464
FOP_SETCC(setnle)
450465
FOP_END;
451466

452-
FOP_START(salc) "pushf; sbb %al, %al; popf \n\t" FOP_RET
467+
FOP_START(salc)
468+
FOP_FUNC(salc)
469+
"pushf; sbb %al, %al; popf \n\t"
470+
FOP_RET(salc)
453471
FOP_END;
454472

455473
/*

arch/x86/kvm/vmx/vmenter.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ ENTRY(vmx_vmenter)
5454
ret
5555

5656
3: cmpb $0, kvm_rebooting
57-
jne 4f
58-
call kvm_spurious_fault
59-
4: ret
57+
je 4f
58+
ret
59+
4: ud2
6060

6161
.pushsection .fixup, "ax"
6262
5: jmp 3b

arch/x86/lib/copy_user_64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ copy_user_handle_tail:
239239
ret
240240

241241
_ASM_EXTABLE_UA(1b, 2b)
242-
ENDPROC(copy_user_handle_tail)
242+
END(copy_user_handle_tail)
243243

244244
/*
245245
* copy_user_nocache - Uncached memory copy with exception handling

arch/x86/lib/getuser.S

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,29 @@ ENDPROC(__get_user_8)
115115
EXPORT_SYMBOL(__get_user_8)
116116

117117

118+
bad_get_user_clac:
119+
ASM_CLAC
118120
bad_get_user:
119121
xor %edx,%edx
120122
mov $(-EFAULT),%_ASM_AX
121-
ASM_CLAC
122123
ret
123-
END(bad_get_user)
124124

125125
#ifdef CONFIG_X86_32
126+
bad_get_user_8_clac:
127+
ASM_CLAC
126128
bad_get_user_8:
127129
xor %edx,%edx
128130
xor %ecx,%ecx
129131
mov $(-EFAULT),%_ASM_AX
130-
ASM_CLAC
131132
ret
132-
END(bad_get_user_8)
133133
#endif
134134

135-
_ASM_EXTABLE_UA(1b, bad_get_user)
136-
_ASM_EXTABLE_UA(2b, bad_get_user)
137-
_ASM_EXTABLE_UA(3b, bad_get_user)
135+
_ASM_EXTABLE_UA(1b, bad_get_user_clac)
136+
_ASM_EXTABLE_UA(2b, bad_get_user_clac)
137+
_ASM_EXTABLE_UA(3b, bad_get_user_clac)
138138
#ifdef CONFIG_X86_64
139-
_ASM_EXTABLE_UA(4b, bad_get_user)
139+
_ASM_EXTABLE_UA(4b, bad_get_user_clac)
140140
#else
141-
_ASM_EXTABLE_UA(4b, bad_get_user_8)
142-
_ASM_EXTABLE_UA(5b, bad_get_user_8)
141+
_ASM_EXTABLE_UA(4b, bad_get_user_8_clac)
142+
_ASM_EXTABLE_UA(5b, bad_get_user_8_clac)
143143
#endif

arch/x86/lib/putuser.S

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
*/
3333

3434
#define ENTER mov PER_CPU_VAR(current_task), %_ASM_BX
35-
#define EXIT ASM_CLAC ; \
36-
ret
3735

3836
.text
3937
ENTRY(__put_user_1)
@@ -43,7 +41,8 @@ ENTRY(__put_user_1)
4341
ASM_STAC
4442
1: movb %al,(%_ASM_CX)
4543
xor %eax,%eax
46-
EXIT
44+
ASM_CLAC
45+
ret
4746
ENDPROC(__put_user_1)
4847
EXPORT_SYMBOL(__put_user_1)
4948

@@ -56,7 +55,8 @@ ENTRY(__put_user_2)
5655
ASM_STAC
5756
2: movw %ax,(%_ASM_CX)
5857
xor %eax,%eax
59-
EXIT
58+
ASM_CLAC
59+
ret
6060
ENDPROC(__put_user_2)
6161
EXPORT_SYMBOL(__put_user_2)
6262

@@ -69,7 +69,8 @@ ENTRY(__put_user_4)
6969
ASM_STAC
7070
3: movl %eax,(%_ASM_CX)
7171
xor %eax,%eax
72-
EXIT
72+
ASM_CLAC
73+
ret
7374
ENDPROC(__put_user_4)
7475
EXPORT_SYMBOL(__put_user_4)
7576

@@ -85,19 +86,21 @@ ENTRY(__put_user_8)
8586
5: movl %edx,4(%_ASM_CX)
8687
#endif
8788
xor %eax,%eax
88-
EXIT
89+
ASM_CLAC
90+
RET
8991
ENDPROC(__put_user_8)
9092
EXPORT_SYMBOL(__put_user_8)
9193

94+
bad_put_user_clac:
95+
ASM_CLAC
9296
bad_put_user:
9397
movl $-EFAULT,%eax
94-
EXIT
95-
END(bad_put_user)
98+
RET
9699

97-
_ASM_EXTABLE_UA(1b, bad_put_user)
98-
_ASM_EXTABLE_UA(2b, bad_put_user)
99-
_ASM_EXTABLE_UA(3b, bad_put_user)
100-
_ASM_EXTABLE_UA(4b, bad_put_user)
100+
_ASM_EXTABLE_UA(1b, bad_put_user_clac)
101+
_ASM_EXTABLE_UA(2b, bad_put_user_clac)
102+
_ASM_EXTABLE_UA(3b, bad_put_user_clac)
103+
_ASM_EXTABLE_UA(4b, bad_put_user_clac)
101104
#ifdef CONFIG_X86_32
102-
_ASM_EXTABLE_UA(5b, bad_put_user)
105+
_ASM_EXTABLE_UA(5b, bad_put_user_clac)
103106
#endif

0 commit comments

Comments
 (0)