Commit ebfef674 authored by Pawan Gupta's avatar Pawan Gupta Committed by Wen Zhiwei
Browse files

x86/entry_32: Do not clobber user EFLAGS.ZF

stable inclusion
from stable-v6.6.58
commit 0c6a7e2c6012cee8273f2b7c1a335a609f8a73b7
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB3BSC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0c6a7e2c6012cee8273f2b7c1a335a609f8a73b7

--------------------------------

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: default avatarJari Ruusu <jariruusu@protonmail.com>
Signed-off-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Cc:stable@vger.kernel.org
Link: https://lore.kernel.org/all/20240925-fix-dosemu-vm86-v7-1-1de0daca2d42%40linux.intel.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 7f79c739
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -875,6 +875,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
@@ -885,7 +887,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.