From nobody Wed Dec 17 09:42:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EAF2CDB474 for ; Fri, 20 Oct 2023 11:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377259AbjJTLhk (ORCPT ); Fri, 20 Oct 2023 07:37:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377175AbjJTLhW (ORCPT ); Fri, 20 Oct 2023 07:37:22 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 668C1D49; Fri, 20 Oct 2023 04:37:19 -0700 (PDT) Date: Fri, 20 Oct 2023 11:37:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697801837; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oIxhgitY3DVGRO2TVqbcuzDD70qUWz8bzmagVZWhTS4=; b=eVtZVok+8EOrucYHFkqIF0MIA+yGlZTBP8g70BGQtYRhlEbMR7D2CLhtbN1aypRv640rTf 2ZAf+P9P+26e1OQtuE45oszz5SqZDQXs/P74CflDyh+RXEB2AUV84mF/N7/F+sC9ibXayr vnZ2OPBbhdXVgrvt9TMexmoLa6XzSulehisqPCY9jFdkUoMijQZ899mDJca8MR1wBL3hvN Sr3LB/OAJezg/51BG++oeDa4HcPMiNW02xJzzCVVkMRdjqFAaa4Ra6/4MtKVfvTsiySVuY +8EY/x1JthQh/f6zJtHv2MSRDZpca1HHVswpLT2I9yntGWow6Cq3dejksfCARQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697801837; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oIxhgitY3DVGRO2TVqbcuzDD70qUWz8bzmagVZWhTS4=; b=mzPR8C587mlqU8x1WXnUcaB51pePxNfFSGiUWT1SqymzPquUq321ZruqLBY7DR/DUlR60V hALGlDeu5YUrhJAg== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/bugs] x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN Cc: Nathan Chancellor , Josh Poimboeuf , "Borislav Petkov (AMD)" , Nick Desaulniers , Marco Elver , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231017165946.v4i2d4exyqwqq3bx@treble> References: <20231017165946.v4i2d4exyqwqq3bx@treble> MIME-Version: 1.0 Message-ID: <169780183325.3135.17534481806232148373.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 2d7ce49f58dc95495b3e22e45d2be7de909b2c63 Gitweb: https://git.kernel.org/tip/2d7ce49f58dc95495b3e22e45d2be7de9= 09b2c63 Author: Josh Poimboeuf AuthorDate: Tue, 17 Oct 2023 09:59:46 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 20 Oct 2023 13:02:23 +02:00 x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN Enabling CONFIG_KCSAN leads to unconverted, default return thunks to remain after patching. As David Kaplan describes in his debugging of the issue, it is caused by a couple of KCSAN-generated constructors which aren't processed by objtool: "When KCSAN is enabled, GCC generates lots of constructor functions named _sub_I_00099_0 which call __tsan_init and then return. The returns in these are generally annotated normally by objtool and fixed up at runtime. But objtool runs on vmlinux.o and vmlinux.o does not include a couple of object files that are in vmlinux, like init/version-timestamp.o and .vmlinux.export.o, both of which contain _sub_I_00099_0 functions. As a result, the returns in these functions are not annotated, and the panic occurs when we call one of them in do_ctors and it uses the default return thunk. This difference can be seen by counting the number of these functions in = the object files: $ objdump -d vmlinux.o|grep -c "<_sub_I_00099_0>:" 2601 $ objdump -d vmlinux|grep -c "<_sub_I_00099_0>:" 2603 If these functions are only run during kernel boot, there is no speculation concern." Fix it by disabling KCSAN on version-timestamp.o and .vmlinux.export.o so the extra functions don't get generated. KASAN and GCOV are already disabled for those files. [ bp: Massage commit message. ] Closes: https://lore.kernel.org/lkml/20231016214810.GA3942238@dev-arch.thel= io-3990X/ Reported-by: Nathan Chancellor Signed-off-by: Josh Poimboeuf Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Nick Desaulniers Acked-by: Marco Elver Tested-by: Nathan Chancellor Link: https://lore.kernel.org/r/20231017165946.v4i2d4exyqwqq3bx@treble --- init/Makefile | 1 + scripts/Makefile.vmlinux | 1 + 2 files changed, 2 insertions(+) diff --git a/init/Makefile b/init/Makefile index ec557ad..cbac576 100644 --- a/init/Makefile +++ b/init/Makefile @@ -60,4 +60,5 @@ include/generated/utsversion.h: FORCE $(obj)/version-timestamp.o: include/generated/utsversion.h CFLAGS_version-timestamp.o :=3D -include include/generated/utsversion.h KASAN_SANITIZE_version-timestamp.o :=3D n +KCSAN_SANITIZE_version-timestamp.o :=3D n GCOV_PROFILE_version-timestamp.o :=3D n diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 3cd6ca1..c9f3e03 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -19,6 +19,7 @@ quiet_cmd_cc_o_c =3D CC $@ =20 ifdef CONFIG_MODULES KASAN_SANITIZE_.vmlinux.export.o :=3D n +KCSAN_SANITIZE_.vmlinux.export.o :=3D n GCOV_PROFILE_.vmlinux.export.o :=3D n targets +=3D .vmlinux.export.o vmlinux: .vmlinux.export.o