From patchwork Tue Aug 30 23:31:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12960165 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BAB8ECAAA1 for ; Wed, 31 Aug 2022 00:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=B6dTj8kXj7lk3zQPuQkPUx4oOWMXfIJpw87KNiGugiI=; b=2ZrXwK79kwZStkFKEqRifhata2 nMGqKTnnIxdjpSyfTPAvy7YE+LNkxPhGZvkP/9OMCFiCCcMr8lRnKV/JWTbex9skBpTLTh7bDS+Ay 2Ylpcd4bdoCVY0xoyDpCfvCSxRJ1qsM2L29k9E2Lk02wZmnBVrWpnrLKu8NSvUUMTVL0uioi8+K4T 3Qnqvia/CCIlhkH24Nszqi9t/wpRHNNBrPZAxbOEAmA5B/D4v8snW+8Ew0NxbZ/ScDJ64+pyIlVYu 39TLtExKPnxH6RuVpUTl3XCySmpIzN1FsAgPm5BsepbPldJcpLnRa1pCs8RkOxXSQ8cDUWFbvkCq+ GCquhgPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oTBDR-002c4p-4v; Wed, 31 Aug 2022 00:04:21 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oTBCQ-002bel-9x for linux-arm-kernel@bombadil.infradead.org; Wed, 31 Aug 2022 00:03:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=QaAhiBNrHu6GYkLFA3B7rG1GS8UtnkRvQfTpKHPiaFU=; b=O0V92aPEbUQeh8tpzWJtV5+G5/ 2cr90lZvTzHT74NN1zsiQPcdi2+ggEdUlvkO/6/M5Qk/3Vxo1bIx5kKn9HAA4ysXl6dO1+5+aUxis vxC0jcdBO4AYo1hPHDVJTMMOwcvusw+wtSDSRo/kXZBaAmT0VyfLw/GB5zLB+TYBt1/N5Wz+rq2Ke WJsdLOihdYp72fRlPJpBWeVuHgXsRfvqLtxftY1fsI4aCSti0xxjfEcxjJv0Z9CbSS6o5YHw9skwx EUQ1jF4XoLUMK1fykfn5a3cEdmeb+mLmhRKcUy2CRc0gvuqK1LptFJgoylsvBzpG50ntx8uUVLNow BPRX4A2w==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oTAiQ-007zjT-6A for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2022 23:32:20 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-335420c7bfeso190449767b3.16 for ; Tue, 30 Aug 2022 16:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date; bh=QaAhiBNrHu6GYkLFA3B7rG1GS8UtnkRvQfTpKHPiaFU=; b=Uzu0hS7fYpQn9SuqY6pJYAs0mwU+Cbcm7VfqttztC5Y7vvGMMQbw4wbd/rsgMajhX8 hCYkTHXcE5WgpL526ftRFAS1iaJreodEJpABN25rLzozJPt3fTcwLmVcYcs0vcC1nhlH yp59OC26/dM0xfLKycIeelmnMx/ctiemiWAngqrglcx45erw27Nl2sLJAj1c3kLUftM8 0iSFHBjA1GYjEC6cZmd4UeYpgAKFk2VTxcYmGZKFX6zgfodGL620Sb3emlMY85C3OcAo bE5fs06VNU0/03FLltVrwNWpMmfeDGopu8w2Crj1CckQW60JmF6IEikz1fcox97zq9e0 FlXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=QaAhiBNrHu6GYkLFA3B7rG1GS8UtnkRvQfTpKHPiaFU=; b=7YTrCrodOC4weJr3GNHacJb+DhX+HnVLgvYTdu5mlTiDCZr7EMQmf40tv+CvnoIvT/ OoQOajLov/+7kVIC7Qz7coVfrS0CZE91omuHv0Jx7rJGYcyYuLUSgofTzXs6ZuGjA5DB bXQGY/aD37iOgYXswiWBByat3YYdaipGwGPSu2ElO6ZQ9WpbR7YVJ5GRix8HQoJknKAm s7zJnEOE0pMiVP2qXQ+sR8zEX6dklmZMI90EbcSAOmpth8k4qqcBu4p9gvJQEbLND8bF jG36P2gWrf/ldjyfGM+OgCI/OdwRB23Xd/prynYlFvEM332vKVbOJMrru5HvbGMayIZx dsXg== X-Gm-Message-State: ACgBeo1ihHmtJZ59ycv+g0DZULjR+uEtxJdnt8pFv+ipBaEO2FCZy/9U Sozp/YsI6RM7Mp64LqctLB4+7lHbx/AqIK3aXX4= X-Google-Smtp-Source: AA6agR4FDK+ca8ExoQOJuxzStWcPg0UmoHQzTdwmwi9npQMvWgOYplZw4nRfd6yLznTzYg9mNTUtUOCVf41ZKmBVqKc= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:54d9:7143:6a7d:91d]) (user=samitolvanen job=sendgmr) by 2002:a0d:d850:0:b0:340:d2c0:b022 with SMTP id a77-20020a0dd850000000b00340d2c0b022mr13497429ywe.469.1661902336610; Tue, 30 Aug 2022 16:32:16 -0700 (PDT) Date: Tue, 30 Aug 2022 16:31:24 -0700 In-Reply-To: <20220830233129.30610-1-samitolvanen@google.com> Message-Id: <20220830233129.30610-17-samitolvanen@google.com> Mime-Version: 1.0 References: <20220830233129.30610-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1745; i=samitolvanen@google.com; h=from:subject; bh=jQm92I9xQfCJPH6jkHCDpzvvJGb/s+FwIZvLF3ZcxmA=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBjDp3OLXWXp4dv7z7QEAEH5wDVXEoy6vQwE4MAgTih TKcGqJ2JAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYw6dzgAKCRBMtfaEi7xW7uhuC/ 4mLD2OTFFRM6dzC+U3G8nSByx2EP7YNHOfYlhOKl0Gv/CfgBF/GmPU6h3gd2FYTdIVAmx+Jt5i7jod yHHS4gZDl8y9ik+cOIJfaq9PCplP1qzBI5UZveW67TQSOg6aWHjQltgyelJnFQOdFAyzVFhcjo1ZT4 RasjgLDZdDZaCQZXWXBTkwjmqg7yGU6nx6FTkZor6xheRDX2kEOcxc/tAIWc/F3tCwLKZO3b2OacxU kLhRFXfTjDHGI8CEMPaaAiF2HgUeJEAfx8o4vhL4zMeTDaKFmRQlmf7F9COJc6E7kag2I6rBVTMLaT FWl2SlSRnYF0zOFsCumLTWzpoCgAijPhDKp/uWc4Bl+x2WAveRz8IYR1rkvZSXXc/Y0/ys9658hItd QLTUDCSGboZ0fd2TFzIbCfImlNrGKDomVDfTKP6XcarqWEI1dc/zyJKjcz0KqduDH2E4Ieu9sxhkpl Xw4LrtrfDpSWz1SEU4GR+7wRiD1adQkP+R3N0lIVY4BnU= X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Subject: [PATCH v4 16/21] objtool: Disable CFI warnings From: Sami Tolvanen To: linux-kernel@vger.kernel.org Cc: Kees Cook , Josh Poimboeuf , Peter Zijlstra , x86@kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Joao Moreira , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Sami Tolvanen X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220831_003218_454247_458E52B6 X-CRM114-Status: GOOD ( 12.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The __cfi_ preambles contain a mov instruction that embeds the KCFI type identifier in the following format: ; type preamble __cfi_function: mov , %eax function: ... While the preamble symbols are STT_FUNC and contain valid instructions, they are never executed and always fall through. Skip the warning for them. .kcfi_traps sections point to CFI traps in text sections. Also skip the warning about them referencing !ENDBR instructions. Signed-off-by: Sami Tolvanen Acked-by: Josh Poimboeuf Reviewed-by: Kees Cook --- tools/objtool/check.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index e55fdf952a3a..48e18737a2d1 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3316,6 +3316,10 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, next_insn = next_insn_to_validate(file, insn); if (func && insn->func && func != insn->func->pfunc) { + /* Ignore KCFI type preambles, which always fall through */ + if (!strncmp(func->name, "__cfi_", 6)) + return 0; + WARN("%s() falls through to next function %s()", func->name, insn->func->name); return 1; @@ -4113,7 +4117,8 @@ static int validate_ibt(struct objtool_file *file) !strcmp(sec->name, "__bug_table") || !strcmp(sec->name, "__ex_table") || !strcmp(sec->name, "__jump_table") || - !strcmp(sec->name, "__mcount_loc")) + !strcmp(sec->name, "__mcount_loc") || + !strcmp(sec->name, ".kcfi_traps")) continue; list_for_each_entry(reloc, &sec->reloc->reloc_list, list)