Skip to content

Commit 67fb9cf

Browse files
kirylPlaidCat
authored andcommitted
x86/coco: Disable 32-bit emulation by default on TDX and SEV
jira VULN-772 cve CVE-2024-25744 commit-author Kirill A. Shutemov <kirill.shutemov@linux.intel.com> commit b82a8db The INT 0x80 instruction is used for 32-bit x86 Linux syscalls. The kernel expects to receive a software interrupt as a result of the INT 0x80 instruction. However, an external interrupt on the same vector triggers the same handler. The kernel interprets an external interrupt on vector 0x80 as a 32-bit system call that came from userspace. A VMM can inject external interrupts on any arbitrary vector at any time. This remains true even for TDX and SEV guests where the VMM is untrusted. Put together, this allows an untrusted VMM to trigger int80 syscall handling at any given point. The content of the guest register file at that moment defines what syscall is triggered and its arguments. It opens the guest OS to manipulation from the VMM side. Disable 32-bit emulation by default for TDX and SEV. User can override it with the ia32_emulation=y command line option. [ dhansen: reword the changelog ] Reported-by: Supraja Sridhara <supraja.sridhara@inf.ethz.ch> Reported-by: Benedict Schlüter <benedict.schlueter@inf.ethz.ch> Reported-by: Mark Kuhne <mark.kuhne@inf.ethz.ch> Reported-by: Andrin Bertschi <andrin.bertschi@inf.ethz.ch> Reported-by: Shweta Shinde <shweta.shinde@inf.ethz.ch> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de> Cc: <stable@vger.kernel.org> # v6.0+: 1da5c9b x86: Introduce ia32_enabled() Cc: <stable@vger.kernel.org> # v6.0+
1 parent 00f43c2 commit 67fb9cf

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

arch/x86/coco/tdx/tdx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <asm/coco.h>
1111
#include <asm/tdx.h>
1212
#include <asm/vmx.h>
13+
#include <asm/ia32.h>
1314
#include <asm/insn.h>
1415
#include <asm/insn-eval.h>
1516
#include <asm/pgtable.h>
@@ -824,5 +825,14 @@ void __init tdx_early_init(void)
824825
x86_platform.guest.enc_tlb_flush_required = tdx_tlb_flush_required;
825826
x86_platform.guest.enc_status_change_finish = tdx_enc_status_changed;
826827

828+
/*
829+
* The VMM is capable of injecting interrupt 0x80 and triggering the
830+
* compatibility syscall path.
831+
*
832+
* By default, the 32-bit emulation is disabled in order to ensure
833+
* the safety of the VM.
834+
*/
835+
ia32_disable();
836+
827837
pr_info("Guest detected\n");
828838
}

arch/x86/include/asm/ia32.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,20 @@ static inline bool ia32_enabled(void)
7575
return __ia32_enabled;
7676
}
7777

78+
static inline void ia32_disable(void)
79+
{
80+
__ia32_enabled = false;
81+
}
82+
7883
#else /* !CONFIG_IA32_EMULATION */
7984

8085
static inline bool ia32_enabled(void)
8186
{
8287
return IS_ENABLED(CONFIG_X86_32);
8388
}
8489

90+
static inline void ia32_disable(void) {}
91+
8592
#endif
8693

8794
#endif /* _ASM_X86_IA32_H */

arch/x86/mm/mem_encrypt_amd.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <asm/msr.h>
3333
#include <asm/cmdline.h>
3434
#include <asm/sev.h>
35+
#include <asm/ia32.h>
3536

3637
#include "mm_internal.h"
3738

@@ -499,6 +500,16 @@ void __init sme_early_init(void)
499500
x86_platform.guest.enc_status_change_finish = amd_enc_status_change_finish;
500501
x86_platform.guest.enc_tlb_flush_required = amd_enc_tlb_flush_required;
501502
x86_platform.guest.enc_cache_flush_required = amd_enc_cache_flush_required;
503+
504+
/*
505+
* The VMM is capable of injecting interrupt 0x80 and triggering the
506+
* compatibility syscall path.
507+
*
508+
* By default, the 32-bit emulation is disabled in order to ensure
509+
* the safety of the VM.
510+
*/
511+
if (sev_status & MSR_AMD64_SEV_ENABLED)
512+
ia32_disable();
502513
}
503514

504515
void __init mem_encrypt_free_decrypted_mem(void)

0 commit comments

Comments
 (0)