]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/i386: user: do not set up a valid LDT on reset
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 13 Oct 2025 16:34:28 +0000 (18:34 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 15 Oct 2025 04:36:30 +0000 (07:36 +0300)
In user-mode emulation, QEMU uses the default setting of the LDT base
and limit, which places it at the bottom 64K of virtual address space.
However, by default there is no LDT at all in Linux processes, and
therefore the limit should be 0.

This is visible as a NULL pointer dereference in LSL and LAR instructions
when they try to read the LDT at an unmapped address.

Resolves: #1376
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 58aa1d08bbc406ba3982f32ffb1bef0ff4f8f369)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/i386/cpu.c

index ab18de894e40a4e9eb4a53a74c7665bf262ed85c..25bbbf70cc1c097202fdc6382ee16e7e02c5b710 100644 (file)
@@ -8632,7 +8632,11 @@ static void x86_cpu_reset_hold(Object *obj, ResetType type)
 
     env->idt.limit = 0xffff;
     env->gdt.limit = 0xffff;
+#if defined(CONFIG_USER_ONLY)
+    env->ldt.limit = 0;
+#else
     env->ldt.limit = 0xffff;
+#endif
     env->ldt.flags = DESC_P_MASK | (2 << DESC_TYPE_SHIFT);
     env->tr.limit = 0xffff;
     env->tr.flags = DESC_P_MASK | (11 << DESC_TYPE_SHIFT);