HomeFreeBSD

amd64: Avoid enabling interrupts when handling kernel mode prot faults

Description

amd64: Avoid enabling interrupts when handling kernel mode prot faults

When PTI is enabled, we may have been on the trampoline stack when iret
faults. So, we have to switch back to the regular stack before
re-entering trap().

trap() has the somewhat strange behaviour of re-enabling interrupts when
handling certain kernel-mode execeptions. In particular, it was doing
this for exceptions raised during execution of iret. When switching
away from the trampoline stack, however, the thread must not be migrated
to a different CPU. Fix the problem by simply leaving interrupts
disabled during the window.

Reported by: syzbot+6cfa544fd86ad4647ffc@syzkaller.appspotmail.com
Reported by: syzbot+cfdfc9e5a8f28f11a7f5@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4a59cbc1253266ea70d6fa43b1a7c77cc33ec6cd)

Details

Provenance
markjAuthored on May 31 2021, 10:49 PM
Parents
rGd330127c17ec: x86: Fix lapic_ipi_alloc() on i386
Branches
Unknown
Tags
Unknown