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 E1F5E16F27E; Mon, 21 Oct 2024 10:32:52 +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=1729506773; cv=none; b=Vcu5oww0C+VUNYxG2nL+99/ye7d3+nRhD+WxcGUfwhScsi3K0MD4RyjwL7bZXFX1cntUxJxOHOWdhOJRvnnuSdYa9qaT/7muh2bmVKXcGfCYnqinx8aE3eIydc63yVDBm8PSO6J/5E198g1pWWT6nQKpqSj+vwwBMkhcPqoGoAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729506773; c=relaxed/simple; bh=JjfWHiN6v/TgLc43ejWZgDpzrnZKDq86mtXTD9t+EtU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V3srB6q6/NpIAeTG8EcySBZhtPjZJ13Yy32OGGL/KE2mf36XTh5JP/HeEJRcc67Ho7rLMX51aXzL3WRtfR8o9Wh902DW49UEPLjA3HQGKpHCqwSDsD2jhF2w8VL9jcRD/MZGjkGKNhF2eRML3uLuoJwkSedY+nivoH87s7vEHTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gh1M6r1B; 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="gh1M6r1B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5966CC4CEC3; Mon, 21 Oct 2024 10:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729506772; bh=JjfWHiN6v/TgLc43ejWZgDpzrnZKDq86mtXTD9t+EtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gh1M6r1B8penVD85sNTgBG87H2tfvxUwyPpD8nnOesfGQgkFUAycOMELTdqavlTPX FkAnbJeg+heyuZuGzGTBz2RKsJsXHOX0qHKT4F1eoS305PVFmz3ZNry0eUgiQRDhrD 9RYGoVH/JthgSRT2EhvuzWpo9FwQ9F7unt5LcacM= 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.11 117/135] x86/entry_32: Do not clobber user EFLAGS.ZF Date: Mon, 21 Oct 2024 12:24:33 +0200 Message-ID: <20241021102303.906093528@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241021102259.324175287@linuxfoundation.org> References: <20241021102259.324175287@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.11-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 @@ -871,6 +871,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 @@ -881,7 +883,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.