HomeFreeBSD

i386: do not allow userspace to set tf_trapno on sigreturn(2)

Description

i386: do not allow userspace to set tf_trapno on sigreturn(2)

tf_trapno is checked on return from interrupt/exception to determine if
special handling is needed for switching address space. This is due to
the possibility of NMI/MCHK/DBG to occur at arbitrary place in kernel,
where both address space and stack used could be transient. Kernel
saves current %cr3 in tf_err for such events, to restore on return.

If user is able to set tf_trapno, it can trigger that special handling,
and since tf_err is also user-controlled by sigreturn(2), the result is
undefined.

PR: 265889
Reported by: lwhsu
Reviewed by: jhb
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D36302

Details

Provenance
kibAuthored on Aug 19 2022, 1:26 AM
Reviewer
jhb
Differential Revision
D36302: Series of fixes for i386
Parents
rGa03e4799e76b: irettraps: i386 does not push %ss/%esp when exception does not switch rings
Branches
Unknown
Tags
Unknown