lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 31 Oct 2022 12:07:45 +0800
From:   Guorui Yu <GuoRui.Yu@...ux.alibaba.com>
To:     kirill.shutemov@...ux.intel.com
Cc:     ak@...ux.intel.com, bp@...en8.de, dan.j.williams@...el.com,
        dave.hansen@...el.com, david@...hat.com, elena.reshetova@...el.com,
        hpa@...or.com, linux-kernel@...r.kernel.org, luto@...nel.org,
        mingo@...hat.com, peterz@...radead.org,
        sathyanarayanan.kuppuswamy@...ux.intel.com, seanjc@...gle.com,
        stable@...r.kernel.org, tglx@...utronix.de,
        thomas.lendacky@....com, x86@...nel.org
Subject: Re: [PATCH 2/2] x86/tdx: Do not allow #VE due to EPT violation on the
 private memory

The core of this vulnerability is not directly related to the 
ATTR_SEPT_VE_DISABLE, but the MMIO processing logic in #VE.

We have encountered similar problems on SEV-ES, here are their fixes on 
Kernel [1] and OVMF[2].

Instead of enforcing the ATTR_SEPT_VE_DISABLE in TDX guest kernel, I 
think the fix should also include necessary check on the MMIO path of 
the #VE routine.

static int handle_mmio(struct pt_regs *regs, struct ve_info *ve)
{
	unsigned long *reg, val, vaddr;
	char buffer[MAX_INSN_SIZE];
	struct insn insn = {};
	enum mmio_type mmio;
	int size, extend_size;
	u8 extend_val = 0;

	// Some addtional security check about ve->gpa should be introduced here.

	/* Only in-kernel MMIO is supported */
	if (WARN_ON_ONCE(user_mode(regs)))
		return -EFAULT;

	// ...
}

If we don't fix the problem at the point where we found, but rely on 
complicated composite logic and long comments in the kernel, I'm 
confident we'll fall back into the same pit in the near future :).


[1] 
https://github.com/torvalds/linux/blob/1a2dcbdde82e3a5f1db9b2f4c48aa1aeba534fb2/arch/x86/kernel/sev.c#L503
[2] OVMF: 
https://github.com/tianocore/edk2/blob/db2c22633f3c761975d8f469a0e195d8b79e1287/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c#L670

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ