Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp953590rdb; Fri, 20 Oct 2023 04:37:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSsX99ncVzXjq+KNfe8tYmGTlObej1HDSzMSw+y/z4YjIm378aj1EjSwlSdGO/r6/9f5D4 X-Received: by 2002:a05:6a20:2451:b0:15d:fc71:1b9e with SMTP id t17-20020a056a20245100b0015dfc711b9emr1556577pzc.49.1697801871954; Fri, 20 Oct 2023 04:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697801871; cv=none; d=google.com; s=arc-20160816; b=hSozf07WqSi8taMoBMLDBK1bMPhDKXTIG3rML6wY+jfFwDQPMCvH4xZMIvJPyuRHae lxNWlQ1BueNRKF7fQt7BYIjUUKOrgljoN+zuTc9sNkGTGMyoyBePwvXov+pPgpf0HH1B MDInl335UaK7dVQ8pjjIJCw7RGdHgmHwn9GeHxdNglgnMStg6r3Sp+a9TIIGrNY4PFdt ssUrI3GTxuAV3I+yJKdb16oR/NmVUT3D4vp6AFn3Q1CEUk9GtcrEaKLz+x5ZSeqXk929 trfOl2EZeoXBDQeKMEWmTr80j5bSgG4EQN83ejsEppCJ6xKFL0knZoPaurV0rlt6x+1U HTsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=oIxhgitY3DVGRO2TVqbcuzDD70qUWz8bzmagVZWhTS4=; fh=pt0k4uCyojabaO/abXkeDeTWofuEzJ+wukq1sHzP004=; b=qOS4oUcMhwa4/4PDJSc5EyVISPN57W52JEw1/y3eOTqNZ26eD3BuG02cDVxdS3y8Cn uG+uxMV8WXBPf4tInQadF13h4FYtcdK2D88dlhfBkvHNEC3AIe6UHoPZ8CDgmZ8H4LgE QL4NpKAhZYBkJqQFOezLyfwG8QSc6ehBR7h9OuCGwa080QebqrknyaOGYTX2UvX5bCe5 uaCpD+p+y0Y2VBZm8glpRQU95zf80R7DhdWn+ulBTdbPDcMdW/vEcEbdR6KizlqPwa8N DnlYDpVjZQ9RASPmeGvVur9qTjE1ouCr6rMb+n1GYjejyg+y32NPs2/ZLplFklniX9rx 7mvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eVtZVok+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h16-20020a17090acf1000b0027717627cf6si4364535pju.41.2023.10.20.04.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eVtZVok+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 50EB982F05D7; Fri, 20 Oct 2023 04:37:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377256AbjJTLhi (ORCPT + 99 others); Fri, 20 Oct 2023 07:37:38 -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: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:37:50 -0700 (PDT) The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 2d7ce49f58dc95495b3e22e45d2be7de909b2c63 Gitweb: https://git.kernel.org/tip/2d7ce49f58dc95495b3e22e45d2be7de909b2c63 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.thelio-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 := -include include/generated/utsversion.h KASAN_SANITIZE_version-timestamp.o := n +KCSAN_SANITIZE_version-timestamp.o := n GCOV_PROFILE_version-timestamp.o := 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 = CC $@ ifdef CONFIG_MODULES KASAN_SANITIZE_.vmlinux.export.o := n +KCSAN_SANITIZE_.vmlinux.export.o := n GCOV_PROFILE_.vmlinux.export.o := n targets += .vmlinux.export.o vmlinux: .vmlinux.export.o