git: 74e7965ac7e6 - stable/15 - amd64: strictly enforce the caller's mode for FRED 64bit syscall handler in C

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 03 Nov 2026 09:02:09 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=74e7965ac7e646c77b2ef79b765f81a6551f0dcd

commit 74e7965ac7e646c77b2ef79b765f81a6551f0dcd
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-28 00:45:33 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-03 09:01:15 +0000

    amd64: strictly enforce the caller's mode for FRED 64bit syscall handler in C
    
    (cherry picked from commit dcc5adb27e3b00f003c2256a9e9aa2fcc20c4d32)
---
 sys/amd64/amd64/trap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index f6b8c904071e..ba0b8a5a233e 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -1670,7 +1670,8 @@ trap_fred_u(struct trapframe_fred *frame)
 	case TF_FRED_EVINFO2_TYPE_SYSCALL:
 		/* Excessive */
 		enable_intr();
-		if (vec == TF_FRED_EVINFO2_VEC_SYSCALL) {
+		if (vec == TF_FRED_EVINFO2_VEC_SYSCALL &&
+		    (frame->tf_idt.tf_fred_evinfo2 & TF_FRED_EVINFO2_LM) != 0) {
 			frame->tf_idt.tf_err = fred_inst_len(frame);
 			td->td_frame = &frame->tf_idt;
 			amd64_syscall(td, (frame->tf_idt.tf_rflags & PSL_T) !=