From patchwork Fri Jun 23 00:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 111856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5434732vqr; Thu, 22 Jun 2023 17:33:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mCs8goEn6y6xxYotCWnRjtc4DyX0p8TRYqWEpRM0dXjuERXjxMqvF1YuBOA6Y+THucrPK X-Received: by 2002:a05:6a00:17a3:b0:668:7fb2:d9a5 with SMTP id s35-20020a056a0017a300b006687fb2d9a5mr18936945pfg.17.1687480384221; Thu, 22 Jun 2023 17:33:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687480384; cv=none; d=google.com; s=arc-20160816; b=yWBuSQtpK1sageuhjXz8mtTDwjWPjeT6G1ISOox808ZoBnAVPTh9kzdu0sa7YKwjhp +dYmZn3f2wHI76Utfw1FtJNRUplldLtR3tuPBfvsusvjeqt9QsAY/Z1QlhiAWalZh6Nq xC2zYUKhYoE0ZBlDcELqlPRiz69GhBdRBn2uRWTi7Ek9TuNbjXuECNrNbmr6fzVx8aaS TaiaSztg6oFp3cQfqv+kODvgfB41w2YWrY4bdemXR1SUlx7hyEPmBOUi95BPIu/uRXMr ed0Q8Qrr3dIEDsXW7fnmy16HmYILlgrDMo6ySKj/Gog9jkpnGr4Ghq5gGFQ56oS6t+U/ DiEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=tThWctNxr0P6K/4oZ/wXBVxJrPYbzfzGbA3tKrbPj+Y=; b=Ajt6mJKeaJoU6qE220dtjkczOl2CD4L1zeq+SvmalNgbdgrf+eHkMUwb9YpKmh67Ly S+EJ0yBRKx7SIDIRwjudrns7OJvuD9Pg4s00Zz7HyOzjrHWFU1CpcuxzpYtHTM3U+K6N i7kN9zYpaW1u9D7ygMbaxDv0eJI6JpCUQQiaKX1wCcg6740cy0a/w45PeXwdiUdQirS5 ISWDvHUVuFpUl/qMS+4yoVq9v4m9Yjys/7d7YAXZ3+N53jrOP/rSKScYX12xTY+JoqRR 2vHdpRCzMFqTaxaDCMpvtNhYYROyAkHyZOkK39rIL+KJNhrbob18/D7Pk35dD2+FIVWF wMDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=5WvHnRo4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y79-20020a626452000000b0063d45a6d0e5si7628765pfb.17.2023.06.22.17.32.51; Thu, 22 Jun 2023 17:33:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=5WvHnRo4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbjFWALu (ORCPT + 99 others); Thu, 22 Jun 2023 20:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231757AbjFWALr (ORCPT ); Thu, 22 Jun 2023 20:11:47 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6271C7 for ; Thu, 22 Jun 2023 17:11:46 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-bc501a1b17fso93657276.3 for ; Thu, 22 Jun 2023 17:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687479106; x=1690071106; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=tThWctNxr0P6K/4oZ/wXBVxJrPYbzfzGbA3tKrbPj+Y=; b=5WvHnRo4OF/MJfUD8mOGhYp1gQyCBXWXyvCkFGb5YqzOnxpmZ4Eq0scfXbv9mzv4ay cpM+qEQ7c+nfUKs4rg7VhcF2FAgSNrDjHUzWaTdg7dCaOSZnEU2RwjYa6O0hxQzocZi2 nYtFSQimWkYUrjFoG9/8ZcaxGUvpPvnqWAgd4dWOaJqbxgeoTB18u1zIOJdxKUza6/El SJxG5/1dyzAdcrrgVLjaca3hRu1GHwUa61MOMdBFzMTQPSdNqRzMsz9jF02hmJscxpcq axcBI5L1v8TaZrMg4IqHF5YCnEhDKKA+UyY09Arso5cwbbm1pCwePzXRmzubX0C3Hw44 9/DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687479106; x=1690071106; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tThWctNxr0P6K/4oZ/wXBVxJrPYbzfzGbA3tKrbPj+Y=; b=NB1yxhrAwPCCuQ1qHHGpfkgWF8vP2Sb5A5F5qpZ75bChwKNq+1WMoR6jGGwc0NOkQY YkMOqS9qyJwNeiCGP4kumbKGm4LGwxe6PkTALqcqgTY/KQCwQ37FxP0l8Bk1Jt5ViKSg y35R1C+mFBrerw2UEeGK113g1mY2KemWs5jYvMbH1RhtycbPZWamPkIZCkH5VUn19mlp 9VTPfINrbNeW+yuMpB3MrB94tiWp3nifWRr3ZLBemQ2CLdBuGYspKnEVZHxGWUE740ac SOvB1V4o6urcJQTNzuiy9OUTRW55P3qAztiPxXardzXvj/w2AQC9bUtB/RNieVYUYr2e j1kg== X-Gm-Message-State: AC+VfDyFUN1su1UodnW4pQ7uWSTw2LcWDl1K/3phL6azOeb9nN7PPCfK aP6MZj9mGwEm8mhVvvMcKF5/LoAStsC1iZ38nI0= X-Received: from samitolvanen.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4f92]) (user=samitolvanen job=sendgmr) by 2002:a25:d30b:0:b0:be7:7690:db57 with SMTP id e11-20020a25d30b000000b00be77690db57mr8154656ybf.1.1687479105997; Thu, 22 Jun 2023 17:11:45 -0700 (PDT) Date: Fri, 23 Jun 2023 00:11:42 +0000 In-Reply-To: <20230623001140.1111494-4-samitolvanen@google.com> Mime-Version: 1.0 References: <20230623001140.1111494-4-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1756; i=samitolvanen@google.com; h=from:subject; bh=Lz/R6d9nIfqb2597G9UKgdcrdHqOlpRtva9W3N3YieY=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBklOM8We2cxfGf1dzuG6LebnHRUj0Vau7v9zch5 7QRtA6fqOOJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCZJTjPAAKCRBMtfaEi7xW 7nulC/wJ80cDBsx2quKpFNhZMKEOutfs60zV2cff1frDXQ95y54zZ33okKLREEf68ErFIJwjk7T yRERrTSxWLuaUWVcMi2RSuPaQUidEicjkC73Lfy/fEm0KQii/1i5j+cDC3DyD1rd5+os1Z7rvwV COrJmytSn99K8nJE1jxf3CzDLq/fiaVVfPhN9IIVqd/BOz7hA/xrkfeZXrx5+MILD3Fhawb6gSf JMezB1pmkfgbpiPcvH4lbItf3OrenTTJL/rIcyTrhlbTPe66SuWPP0DfRVpfwJUmJjDl37InI2U UZbNCJmk8sIgF/CYpw9O5KBdUaXrJT7JVOHMtRp4R3W2kridrkLV6w1w93x8AtYWKyHxEgH6WKO xQ+sUNZ+mnokdZrRIaFb0XlBu86zYvLM39ooK/fd0BBO8trTDG8/NINvbChn49JQ8yugKop7pnE 2B1EjFV+5+I9rJw7WVEgp94GLcnI4z+QXpATrhLKXTN8/qyvUg4O8qa7Fs2es7YZFKd2U= X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230623001140.1111494-5-samitolvanen@google.com> Subject: [PATCH 1/2] kbuild: Fix CFI failures with GCOV From: Sami Tolvanen To: Masahiro Yamada , "Peter Zijlstra (Intel)" , Kees Cook Cc: Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Tom Rix , linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Sami Tolvanen , Joe Fradley X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769451431397700864?= X-GMAIL-MSGID: =?utf-8?q?1769451431397700864?= With GCOV_PROFILE_ALL, Clang injects __llvm_gcov_* functions to each object file, and the functions are indirectly called during boot. However, when code is injected to object files that are not part of vmlinux.o, it's also not processed by objtool, which breaks CFI hash randomization as the hashes in these files won't be included in the .cfi_sites section and thus won't be randomized. Similarly to commit 42633ed852de ("kbuild: Fix CFI hash randomization with KASAN"), disable GCOV for .vmlinux.export.o and init/version-timestamp.o to avoid emitting unnecessary functions to object files that don't otherwise have executable code. Fixes: 0c3e806ec0f9 ("x86/cfi: Add boot time hash randomization") Reported-by: Joe Fradley Signed-off-by: Sami Tolvanen --- init/Makefile | 1 + scripts/Makefile.vmlinux | 1 + 2 files changed, 2 insertions(+) diff --git a/init/Makefile b/init/Makefile index 26de459006c4..ec557ada3c12 100644 --- a/init/Makefile +++ b/init/Makefile @@ -60,3 +60,4 @@ 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 +GCOV_PROFILE_version-timestamp.o := n diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 10176dec97ea..3cd6ca15f390 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 +GCOV_PROFILE_.vmlinux.export.o := n targets += .vmlinux.export.o vmlinux: .vmlinux.export.o endif From patchwork Fri Jun 23 00:11:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 111858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5435469vqr; Thu, 22 Jun 2023 17:35:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ54NCu8pY2U4fR+Th7f3g+AEkn2zUI4V8Red+QRaCcTwQWXxaUGG2EfwE/AHPt8nZhws9R8 X-Received: by 2002:a05:6358:45a:b0:125:6f8e:67e9 with SMTP id 26-20020a056358045a00b001256f8e67e9mr9215261rwe.18.1687480510232; Thu, 22 Jun 2023 17:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687480510; cv=none; d=google.com; s=arc-20160816; b=mcilBW5wa19JvyHPgp4/FO6dBCBQHczW/EP+340PvhfDCtHJrFZrpWBLo6XRleQPto N+sADFEYc30XEQE6io7I5Y/PudkOn9OrmA9WPdrEDgylfFWc2FNPlhsCP4IDpoJqEj8n liGpn1Mezg16SqSayDqEGFEwmtYO+C5zqhsnCHrt2rYbIdjNSFxSV0q6oDdqLM2YccXi ctKjidr5kI5AZuYlaEBgfNnqe5LNrpd23EbWuobypCb8f3Ey7CLKLt/iJaBLYv1DynZ/ JAjzbnIzzimKJ3Yg5A/Pi48T/y5+PzMVKahq6EuKmfXkzv5IoiKTqhakoSyNZUqv9SUw kwmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vo1O88LBn12GePGGmuhdEP/k87jpAuHnXHVbobu4PRQ=; b=q4YQJsuJFYFThhHhyxqtpL9AdfSU5D4AgDepbwC3vXz/zwPJniwi+tO+sdXwDJruQ6 9qi4b2gkG+etSYfKCBr+5ScvDP7fkwShL+gQVx4IiiLqutzQeX/yq1gTrOoYe9BG4aMb hwSz4FgT1zAEwvsAceJmoxSHuDaN9vF2rsSXhgJSyliNN7sHtHFYNyjlPQaojmgUPE+E ZlcvSV91SGTB3O4oI2opTLcu41udR7qu8Xalnm3iUKESmVIggjz4FsxgUe8IzJroRS5D UyIrxBlwN35IWeqP/LTqHWDunBPu4gEa8WNLQz55/curX6QdQLqkFe3Ml2QgHfW2NPDY LLAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=QksAuYQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a63934c000000b005348fd7cb66si8126985pgm.873.2023.06.22.17.34.57; Thu, 22 Jun 2023 17:35:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=QksAuYQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231874AbjFWALy (ORCPT + 99 others); Thu, 22 Jun 2023 20:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231658AbjFWALt (ORCPT ); Thu, 22 Jun 2023 20:11:49 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8841AC7 for ; Thu, 22 Jun 2023 17:11:48 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1b52f9b8b19so185245ad.1 for ; Thu, 22 Jun 2023 17:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687479108; x=1690071108; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vo1O88LBn12GePGGmuhdEP/k87jpAuHnXHVbobu4PRQ=; b=QksAuYQ4h9HkiWUUDuUJe286BNS/KxSd9WfVtRDqdPoNN9R3SdorrFx4XiozyaaNG7 Rb8GIkwqVwR0lMbldf+pOEFtxPakHz9Zizvom7UKdoWLLi5HCtAoIBcbLhEu3x7JI0EF q8YmN9W2MVTs0f/67FbgxFfm1i6YOJ+ynwnLsu8VEVI+ARdpUGz0vXwxmVY/DdPJyU4j CXoSh0ehZHdwKxkNmjS0wQ/6y+KuhZsG0uXdbaVwWahEY/HgR6pc23egaX89uG1CExlM CV0acJV5vk2D9HpYijnsHbuCykfCGu6WCWzCrk7XS0hUlZAy85YXtaRPg8jD8qGp6BRs OCiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687479108; x=1690071108; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vo1O88LBn12GePGGmuhdEP/k87jpAuHnXHVbobu4PRQ=; b=N7YDD5TR3odFgU9BBLI3htYt1e1A/pE28a29KJQS1Kbgq2Lbc5YA8ItjGlnj8Kl9hv gmm6SQnlQhVsnc9Jljyar6P3/5f+2aS6VYV8vooMCrOE+nGdTjIT/d0yxdrwBc2WZyKf xdDMSNrDA20Z9jk3cqZ690tbeDqKm3o7KRQd3Jt32+SaQGj3ETHT/YQJdknL1X4XA+UE hvb04NOvnqe7WZiQlPX1pxGUI4Y2XmEWLdzpKwu9t1Rb2aSqzvvcJf0iql0sWIdlt5+p O8HYwi6g3VsrwOtDVMkDOprBQKp9DMomZxLIFAaY+PIrwFw5TghgkFbo/E7cNWlRVhZV CXfQ== X-Gm-Message-State: AC+VfDzTzzDtmuj76P4vPpLg2OO9A9/CJR2KRFAS28qS7Ii4B/CAiwSW bxGpEMtldGqnyON9aK7wu2q9v3dR2oePTV4QVTQ= X-Received: from samitolvanen.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4f92]) (user=samitolvanen job=sendgmr) by 2002:a17:902:f811:b0:1a2:3436:4119 with SMTP id ix17-20020a170902f81100b001a234364119mr2901699plb.8.1687479108018; Thu, 22 Jun 2023 17:11:48 -0700 (PDT) Date: Fri, 23 Jun 2023 00:11:43 +0000 In-Reply-To: <20230623001140.1111494-4-samitolvanen@google.com> Mime-Version: 1.0 References: <20230623001140.1111494-4-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1491; i=samitolvanen@google.com; h=from:subject; bh=vz8JtYFBMZ6JrswVYldeog2RjlQc50BCAyUkbrZYc88=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBklOM9pyZClW2Hp8UbFrWSquBEPCjWlPQquZ198 cauUcsQF4CJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCZJTjPQAKCRBMtfaEi7xW 7vh7C/42zRx8PHZksPRLtj/W3ew78/fa4rX9uyohW/fQWdFjU353MF0DOlLvB+HMwvd2ScZzNJc A2Q59WjNYMQI66abJdyKo53NSJaFpKE9jUguxSMEbg94h+97MmLb+I783T1xWnA9/s5XAyXy2CG 6vTmjFnSter4GgvRm/1L2a/Xr4xfsfpr2cQSe5moZKEN5w6z2SjKp/xUuvFkd6b+3Uj7t5jf7U9 Eg/3aV4wP3Ear17oOZ/56pcr7tuFb7RSWTyBcFkaoE6OUSfkk4k40eI1kwyqGaQCMdWB3YxWxjd Koe2LaCPMhC+vSRPiwMoRwSntCi02YciGfW+S7XXKUt/CazCfkNcSPcjqtOUt1Jah73z/j8PkSY ODqPGiSGUHMVQuUcKK+LHaZkpr+EKJok+pFYvu2LlREZVJeiCL0fg2q6Vro/M2AX1t2XtJH869U +eOKmEGBoBmH2K5IGBMFShQFH5V+Xtj0bo6fwZ45aW3fGOdeffsUXqNzzrS9lRYwBcIzo= X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230623001140.1111494-6-samitolvanen@google.com> Subject: [PATCH 2/2] kbuild: Disable GCOV for *.mod.o From: Sami Tolvanen To: Masahiro Yamada , "Peter Zijlstra (Intel)" , Kees Cook Cc: Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Tom Rix , linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Sami Tolvanen , Joe Fradley X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769451563327385122?= X-GMAIL-MSGID: =?utf-8?q?1769451563327385122?= With GCOV_PROFILE_ALL, Clang injects __llvm_gcov_* functions to each object file, including the *.mod.o. As we filter out CC_FLAGS_CFI for *.mod.o, the compiler won't generate type hashes for the injected functions, and therefore indirectly calling them during module loading trips indirect call checking. Enabling CFI for *.mod.o isn't sufficient to fix this issue after commit 0c3e806ec0f9 ("x86/cfi: Add boot time hash randomization"), as *.mod.o aren't processed by objtool, which means any hashes emitted there won't be randomized. Therefore, in addition to disabling CFI for *.mod.o, also disable GCOV, as the object files don't otherwise contain any executable code. Fixes: cf68fffb66d6 ("add support for Clang CFI") Reported-by: Joe Fradley Signed-off-by: Sami Tolvanen --- scripts/Makefile.modfinal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 4703f652c009..fc19f67039bd 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -23,7 +23,7 @@ modname = $(notdir $(@:.mod.o=)) part-of-module = y quiet_cmd_cc_o_c = CC [M] $@ - cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI), $(c_flags)) -c -o $@ $< + cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI) $(CFLAGS_GCOV), $(c_flags)) -c -o $@ $< %.mod.o: %.mod.c FORCE $(call if_changed_dep,cc_o_c)