Skip to content

Commit

Permalink
OS-7064 failed elfexec leads to segnp, and worse
Browse files Browse the repository at this point in the history
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
  • Loading branch information
John Levon committed Jul 30, 2018
1 parent d9c6fa6 commit 5a38f11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
7 changes: 6 additions & 1 deletion usr/src/uts/i86pc/ml/kpti_trampolines.s
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ kpti_kbase:
* This is used for all interrupts that can plausibly be taken inside another
* interrupt and are using a kpti_frame stack (so #BP, #DB, #GP, #PF, #SS).
*
* We also use this for #NP, even though it uses the standard IST: the
* additional %rsp checks below will catch when we get an exception doing an
* iret to userspace with a bad %cs/%ss. This appears as a kernel trap, and
* only later gets redirected via kern_gpfault().
*
* We check for whether we took the interrupt while in another trampoline, in
* which case we need to use the kthread stack.
*/
Expand Down Expand Up @@ -649,7 +654,7 @@ tr_intr_ret_end:
MK_INTR_TRAMPOLINE_NOERR(invoptrap)
MK_INTR_TRAMPOLINE_NOERR(ndptrap)
MK_INTR_TRAMPOLINE(invtsstrap)
MK_INTR_TRAMPOLINE(segnptrap)
MK_DBG_INTR_TRAMPOLINE(segnptrap)
MK_DBG_INTR_TRAMPOLINE(stktrap)
MK_DBG_INTR_TRAMPOLINE(gptrap)
MK_DBG_INTR_TRAMPOLINE(pftrap)
Expand Down
23 changes: 12 additions & 11 deletions usr/src/uts/i86pc/ml/locore.s
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ _locore_start(struct boot_syscalls *sysp, ulong_t rsi, struct bootops *bop)
* %rdi = boot services (should die someday)
* %rdx = bootops
* end
*/
*/

leaq edata(%rip), %rbp /* reference edata for ksyms */
movq $0, (%rbp) /* limit stack back trace */
Expand All @@ -178,7 +178,7 @@ _locore_start(struct boot_syscalls *sysp, ulong_t rsi, struct bootops *bop)
#endif
/*
* Save call back for special x86 boot services vector
*/
*/
movq %rdi, sysp(%rip)

movq %rdx, bootops(%rip) /* save bootops */
Expand Down Expand Up @@ -208,7 +208,7 @@ _locore_start(struct boot_syscalls *sysp, ulong_t rsi, struct bootops *bop)
#endif /* __xpv */

/*
* (We just assert this works by virtue of being here)
* (We just assert this works by virtue of being here)
*/
bts $X86FSET_CPUID, x86_featureset(%rip)

Expand Down Expand Up @@ -268,7 +268,7 @@ _locore_start(struct boot_syscalls *sysp, struct bootops *bop)
/*
* %ecx = boot services (should die someday)
* %ebx = bootops
*/
*/
mov $edata, %ebp / edata needs to be defined for ksyms
movl $0, (%ebp) / limit stack back trace

Expand All @@ -283,14 +283,14 @@ _locore_start(struct boot_syscalls *sysp, struct bootops *bop)
*/
mov %ecx, sysp / save call back for boot services

mov %ebx, bootops / save bootops
mov %ebx, bootops / save bootops
movl $bootops, bootopsp


/*
* Save all registers and flags
*/
pushal
pushal
pushfl

#if !defined(__xpv)
Expand Down Expand Up @@ -443,7 +443,7 @@ port_22_free:
* cycle. If the CCR index was not valid for this Cyrix model, we may
* have performed an external I/O cycle as well. In these cases and
* if the motherboard/chipset vendor ignores I/O address line A1,
* then the PIC will have IRQ3 set at the lowest priority as a side
* then the PIC will have IRQ3 set at the lowest priority as a side
* effect of the above outb. We are reasonalbly confident that there
* is not an unknown device on I/O port 0x22, so there should have been
* no unpredictable side-effect of the above outb.
Expand Down Expand Up @@ -892,7 +892,7 @@ likelyM3:
* now we will call anything with a DIR0 of 0x80 or higher an MIII.
* The MIII is supposed to support large pages, but we will believe
* it when we see it. For now we just enable and test for MII features.
*/
*/
movl $X86_TYPE_VIA_CYRIX_III, x86_type
jmp likeMII

Expand Down Expand Up @@ -930,7 +930,7 @@ coma_bug:
* fixed this bug sometime late in 1997 and no other exploits other than
* xchgl have been discovered is good indication that this workaround is
* reasonable.
*/
*/

.set CYRIX_DBR0, 0x30 / Debug Register 0
.set CYRIX_DBR1, 0x31 / Debug Register 1
Expand All @@ -939,7 +939,7 @@ coma_bug:
.set CYRIX_DOR, 0x3c / Debug Opcode Register

/*
* What is known about DBR1, DBR2, DBR3, and DOR is that for normal
* What is known about DBR1, DBR2, DBR3, and DOR is that for normal
* cpu execution DBR1, DBR2, and DBR3 are set to 0. To obtain opcode
* serialization, DBR1, DBR2, and DBR3 are loaded with 0xb8, 0x7f,
* and 0xff. Then, DOR is loaded with the one byte opcode.
Expand Down Expand Up @@ -999,7 +999,7 @@ coma_bug:
/*
* write DBR1
*/
movb $CYRIX_DBR1, %al
movb $CYRIX_DBR1, %al
outb $CYRIX_CRI
movb $0xf8, %al
outb $CYRIX_CRD
Expand Down Expand Up @@ -1201,6 +1201,7 @@ cmntrap()
leaq dtrace_badtrap(%rip), %rdi
xorl %eax, %eax
call panic
SET_SIZE(cmntrap_pushed)
SET_SIZE(cmntrap)
SET_SIZE(_cmntrap)

Expand Down

0 comments on commit 5a38f11

Please sign in to comment.