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 498391E32B1; Mon, 21 Oct 2024 10:44:08 +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=1729507448; cv=none; b=Uy3juPz9RVsCy7x0jfsyDUTb7o0lW9LA/F7U1CXD9/dD+J66UloypvejZkX5AXwhGrfYGsRbLuAE+qB+i+DmQW6hCmAne1IAnPciIcFqKfwxVmTXeB/xAKZsZUjv2V/jT3K/PeeU/pvPK8Im+S1OaK2izE1bICupyzfd/BtWDSo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729507448; c=relaxed/simple; bh=NrmSnASakjSdDst1xf6V1jeo4IHxfztWsf3LOycECU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q6+nNLx7a1sJcg69ONVwmN93j1qm86ZoK01L1y2K1jWNiAJfvl8AM4cHS2dEM1YfeLNYsBpogdcmWw4Rlw1LVfzzZJz4x2j/eF3qIgtjYAu9VViXieBpEHc4sVsnQejdoIKh8Uve69tsl6mAIYjzhP7w1rEsxrBKBUxipDGGRn4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nVNLkkKR; 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="nVNLkkKR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDFEFC4CEC3; Mon, 21 Oct 2024 10:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729507448; bh=NrmSnASakjSdDst1xf6V1jeo4IHxfztWsf3LOycECU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVNLkkKRAr2SALbHJePtk68SB0IRUlUmnhNDWDlZiskhfZbRgC1FFGjnNPIkGtRgQ pVF/PX3XCuk5jhar2pC0G963YNCh/f2/5Tc7NPtR91eX2x6jp00q+5iBnpc5pwAD1N Hwr0Xf90Pa2kCPDcNyFnJ4Pw9IYASZZB4YSdZyPU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jari Ruusu , Pawan Gupta , Dave Hansen Subject: [PATCH 6.1 80/91] x86/entry_32: Do not clobber user EFLAGS.ZF Date: Mon, 21 Oct 2024 12:25:34 +0200 Message-ID: <20241021102252.936320978@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241021102249.791942892@linuxfoundation.org> References: <20241021102249.791942892@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pawan Gupta commit 2e2e5143d4868163d6756c8c6a4d28cbfa5245e5 upstream. Opportunistic SYSEXIT executes VERW to clear CPU buffers after user EFLAGS are restored. This can clobber user EFLAGS.ZF. Move CLEAR_CPU_BUFFERS before the user EFLAGS are restored. This ensures that the user EFLAGS.ZF is not clobbered. Closes: https://lore.kernel.org/lkml/yVXwe8gvgmPADpRB6lXlicS2fcHoV5OHHxyuFbB_MEleRPD7-KhGe5VtORejtPe-KCkT8Uhcg5d7-IBw4Ojb4H7z5LQxoZylSmJ8KNL3A8o=@protonmail.com/ Fixes: a0e2dab44d22 ("x86/entry_32: Add VERW just before userspace transition") Reported-by: Jari Ruusu Signed-off-by: Pawan Gupta Signed-off-by: Dave Hansen Cc:stable@vger.kernel.org Link: https://lore.kernel.org/all/20240925-fix-dosemu-vm86-v7-1-1de0daca2d42%40linux.intel.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/entry/entry_32.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -902,6 +902,8 @@ SYM_FUNC_START(entry_SYSENTER_32) /* Now ready to switch the cr3 */ SWITCH_TO_USER_CR3 scratch_reg=%eax + /* Clobbers ZF */ + CLEAR_CPU_BUFFERS /* * Restore all flags except IF. (We restore IF separately because @@ -912,7 +914,6 @@ SYM_FUNC_START(entry_SYSENTER_32) BUG_IF_WRONG_CR3 no_user_check=1 popfl popl %eax - CLEAR_CPU_BUFFERS /* * Return back to the vDSO, which will pop ecx and edx.