[tip:,x86/bugs] x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN
Message ID | 169780183325.3135.17534481806232148373.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp990650vqb; Fri, 20 Oct 2023 04:38:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXzEiG+J0Jt/rvbtt6SoB9KP1TcnbhKgpePYMPcVNFKFNaKzv/Q+Tafm6Ljy6F6JBFE8Z3 X-Received: by 2002:a17:902:d04c:b0:1c9:c97b:ebad with SMTP id l12-20020a170902d04c00b001c9c97bebadmr1270086pll.34.1697801903269; Fri, 20 Oct 2023 04:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697801903; cv=none; d=google.com; s=arc-20160816; b=idrXa44x+PQeBm1jGtZi+40CAd/3FKlIWYTKmbjgxbdn0YkGvtnUEnqg0K/VI2n56S RDRL8DYNTtopKBOrhPYdyEGPrHbbJyUDrWOx8F9Mimv4aVsEgbQkOteorcfc6ny98Lwh V0kOqVE37xQ2KPcVrwJ6wlCJCyNOIv+VJMOF7s1WmTsyALoEXeLGeWZm2cRxA24iiINb EDEe/CSthK4Iq+UFzRnasHQ4xH5X8Kzc7slwuFRg+y1f2OF0haPVsWZaI6lT8iz0v170 kX/liGQdkrFIfsHfi/tgns1ByFTCy3rR0GVApVG9tQ27N0BaufRy3IIwDj3HtNUEAajz eOXw== 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id i6-20020a170902eb4600b001c32d285db8si1498248pli.308.2023.10.20.04.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:38:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 9FCE48359381; Fri, 20 Oct 2023 04:38:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377217AbjJTLhj (ORCPT <rfc822;lkml4gm@gmail.com> + 25 others); Fri, 20 Oct 2023 07:37:39 -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 <rfc822;linux-kernel@vger.kernel.org>); 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" <tip-bot2@linutronix.de> 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 <nathan@kernel.org>, Josh Poimboeuf <jpoimboe@kernel.org>, "Borislav Petkov (AMD)" <bp@alien8.de>, Nick Desaulniers <ndesaulniers@google.com>, Marco Elver <elver@google.com>, 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: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:38:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780026084721726565 X-GMAIL-MSGID: 1780274328552432322 |
Series |
[tip:,x86/bugs] x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN
|
|
Commit Message
tip-bot2 for Thomas Gleixner
Oct. 20, 2023, 11:37 a.m. UTC
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 <jpoimboe@kernel.org> AuthorDate: Tue, 17 Oct 2023 09:59:46 -07:00 Committer: Borislav Petkov (AMD) <bp@alien8.de> 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 <nathan@kernel.org> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Acked-by: Marco Elver <elver@google.com> Tested-by: Nathan Chancellor <nathan@kernel.org> 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