From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE0723218BA; Mon, 27 Oct 2025 18:44:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761590656; cv=none; b=repUJOW4eAMmSI2shngE6mVmgyBxI9IqrufZyvL2RcIMLyYXSxULIosvjDOEdw2I697KfxuXJGe8GLJ+tcuMpdCPgCwfCKShccDx7O7iusHarm1pWq+o1OPzJYpjd0ghRIOsXR2laUXCubCEENOYhmRg0F/l3I0pYBK2YooC6ug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761590656; c=relaxed/simple; bh=2eb2adhDNQeCd8uRAWip7TEAgYx+SbPmqWz3cqwvEdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GC9c09lJA6Slnwsd9Yl9lwHyMiWEs0paLL3n0RrTe5yyqPRstcpQIcqMzMpHz7CSC6w83gceEjqfjSSe8lhQRkSXmwl4lHwp7wrfQjTGJ+lUxKPkFd9lCn/J3wRcCddoUybb2SrlcKnERvIx094QrffL9QBtq6kTJVg5HWr+bgo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ho1O4cI4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ho1O4cI4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BEE8C4CEF1; Mon, 27 Oct 2025 18:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761590656; bh=2eb2adhDNQeCd8uRAWip7TEAgYx+SbPmqWz3cqwvEdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ho1O4cI4NenIa2QCFJyldrJa1i41ltlq2UykCuboj4hENuIXkDghfajyOMbim8Z2A cegNfg6ygKd5+kQQpLc52CbjIGCeQBzfpmVDRKlpiqLjJHG+Q79sYX/jitUflzig65 op4zPylmxS1By5SC2L0Aexz8FzJtIxZERVJ4nSns= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sean Christopherson , "Borislav Petkov (AMD)" , "Peter Zijlstra (Intel)" Subject: [PATCH 5.4 127/224] x86/umip: Fix decoding of register forms of 0F 01 (SGDT and SIDT aliases) Date: Mon, 27 Oct 2025 19:34:33 +0100 Message-ID: <20251027183512.376089780@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183508.963233542@linuxfoundation.org> References: <20251027183508.963233542@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sean Christopherson commit 27b1fd62012dfe9d3eb8ecde344d7aa673695ecf upstream. Filter out the register forms of 0F 01 when determining whether or not to emulate in response to a potential UMIP violation #GP, as SGDT and SIDT only accept memory operands. The register variants of 0F 01 are used to encode instructions for things like VMX and SGX, i.e. not checking the Mod field would cause the kernel to incorrectly emulate on #GP, e.g. due to a CPL violation on VMLAUNCH. Fixes: 1e5db223696a ("x86/umip: Add emulation code for UMIP instructions") Signed-off-by: Sean Christopherson Signed-off-by: Borislav Petkov (AMD) Acked-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/umip.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/arch/x86/kernel/umip.c +++ b/arch/x86/kernel/umip.c @@ -162,8 +162,19 @@ static int identify_insn(struct insn *in if (insn->opcode.bytes[1] == 0x1) { switch (X86_MODRM_REG(insn->modrm.value)) { case 0: + /* The reg form of 0F 01 /0 encodes VMX instructions. */ + if (X86_MODRM_MOD(insn->modrm.value) == 3) + return -EINVAL; + return UMIP_INST_SGDT; case 1: + /* + * The reg form of 0F 01 /1 encodes MONITOR/MWAIT, + * STAC/CLAC, and ENCLS. + */ + if (X86_MODRM_MOD(insn->modrm.value) == 3) + return -EINVAL; + return UMIP_INST_SIDT; case 4: return UMIP_INST_SMSW;