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 4D1931E4A9; Fri, 5 Jan 2024 14:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="T9RYNQq2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D8A1C433C8; Fri, 5 Jan 2024 14:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1704465697; bh=SC08ELtiqbmTJqYaUwrcWDOFyKzbx63KHxq/Z8Ken0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9RYNQq2pY9BFawYztxlmqfioH9DAHnZuZPxyQvbUtMfomrilHW0BZuPTl0ke3Ufq 6ZdCebNgN9/UErhK0az9KaizEg6HMP3DxHkm4ysGlsHdE1gU5PnwUFI7ecv4lvBjGD rjJ/gwnj/oAsdoMOVkiQfBlmuaRotpugs6tpWSFE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Gleixner , "Borislav Petkov (AMD)" , "Peter Zijlstra (Intel)" , stable@kernel.org Subject: [PATCH 4.19 36/41] x86/alternatives: Sync core before enabling interrupts Date: Fri, 5 Jan 2024 15:39:16 +0100 Message-ID: <20240105143815.411646378@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105143813.957669139@linuxfoundation.org> References: <20240105143813.957669139@linuxfoundation.org> User-Agent: quilt/0.67 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit 3ea1704a92967834bf0e64ca1205db4680d04048 upstream. text_poke_early() does: local_irq_save(flags); memcpy(addr, opcode, len); local_irq_restore(flags); sync_core(); That's not really correct because the synchronization should happen before interrupts are re-enabled to ensure that a pending interrupt observes the complete update of the opcodes. It's not entirely clear whether the interrupt entry provides enough serialization already, but moving the sync_core() invocation into interrupt disabled region does no harm and is obviously correct. Fixes: 6fffacb30349 ("x86/alternatives, jumplabel: Use text_poke_early() before mm_init()") Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Acked-by: Peter Zijlstra (Intel) Cc: Link: https://lore.kernel.org/r/ZT6narvE%2BLxX%2B7Be@windriver.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/alternative.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -690,8 +690,8 @@ void *__init_or_module text_poke_early(v } else { local_irq_save(flags); memcpy(addr, opcode, len); - local_irq_restore(flags); sync_core(); + local_irq_restore(flags); /* * Could also do a CLFLUSH here to speed up CPU recovery; but