From patchwork Fri Jun 10 23:35:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12878215 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 59A6DCCA47C for ; Sat, 11 Jun 2022 00:42:18 +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=voeVj01GaBFwzi0UDREaMuQsNBK8pHe5E2656ElNcs8=; b=gZJn9KPMBSs3xbLdPctKXL4UdU Va6XxusLm27k8V2XI5an2pCam1LsxM2oGZ8R2UWaDohREje53HPLfbsQ0gOjFUE4AXHPsN1V559VD 0bMk4OSscmHGeW5sLYzfpmlGtFpa7seSq8Oe09P6Mky4yOozpcTV0iHPecDtaQOf5brHYsWedV5k/ y91hoiWAuLKoW150sMrqnQfi92mfjRpJ2sIyPYttrobP4v3WXspKTcK4RG6srrhrEws/o2CZDGDy7 obOY+96Ro+Hx3Rbf66y0CZBMEYItCAzNo/kXO+hS9OkGLellSuUR+S606byXSmkQSL1S1t9C5XAgy om3PoY4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzpBF-00AfXO-Gk; Sat, 11 Jun 2022 00:40:45 +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 1nzpBC-00AfUK-Nh for linux-arm-kernel@bombadil.infradead.org; Sat, 11 Jun 2022 00:40:42 +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=Y96fv5Twtvzm6CyIpXWKw8Jd94PeG6V8wybz0+yAnX8=; b=ejh+T9gK6/W1YxfxQfVY24GGbr 3R4MXplUpeHgcmL8HHIDCP8K+LyW2G7piZZeUGYoKqbepSr/udzFWvVvRsj0ONJMRDBTj7ugO6cg0 Kx7cQyUz5BpxCZnHHxxFYf5qvQap7p2JwY9yvO5i8Tzvklhrudvt69EHPpaDxtv8IGVLQDeeMFc3l MvGTFgUIdnOdl4t/RupLsgkM/g3RyAOqPuzS6Ujs9v5CreJU6o4Tm98m3JXfcIe7/TEkx35YVXe3L 4iG6sYo2+9rE8cxTY/lQxKzYVn0Dqna6cuPzhPmpeGpjr8Ss0kUR1xwp9MzDh0N7s2Y6nj4FeEh9W KcnEIatw==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzoAV-006oFz-Oq for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 23:35:58 +0000 Received: by mail-yb1-xb49.google.com with SMTP id v7-20020a254807000000b006645e99f4faso588349yba.1 for ; Fri, 10 Jun 2022 16:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Y96fv5Twtvzm6CyIpXWKw8Jd94PeG6V8wybz0+yAnX8=; b=IOPZc5JV3nT2LYllhUNSqQYadg1pAF7x0nJHGRfuoOldyA3IF4MfcUfi28kwW9bjK3 ZkOn4EyemcOKcBZ4lvbRoM88zdr4pP/X6pNrmQS+Trrh16VsFWzR/ivvrnkgTFcOEBeq zh4c1XSjaFca/mNv67WEZZRQg6ZyEcv2WeJgQKjPKDJ+6inRCnLsR02LvK76lq7rrygX kc4b07GD1ORl1Vkg+OCQkeYlNtADbEXYf/V4ORhUII4xOAh9HLKlgJsAnnSOy3K+JaGt GLg2Vk1h8xnuWJsYbO4m9Twpc05icIIuVq5OYgfBIvRgF9MT/sXYCcHdZ4chr4Z9vQ5Q kXOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Y96fv5Twtvzm6CyIpXWKw8Jd94PeG6V8wybz0+yAnX8=; b=rafXA8dkVkliZy71ETrzsshqjwyP/oF5RO1VTS7NDVbV68bpIeCNIi0nQz38tqaU1p qG2ZFw8FlIxCNK1rNA/FoiEl8XT5hotaCZBj5p0dbp70r3+mk4bUnsxOPu9SBoRnc/oN e5sckYgzYmBscFBIp+Y9E8nYnao2WqNojULboVFlH3wO3WNsuOSJjq6IVj++yy1QG+4D tCEURQt+t4NwGnUpRe4oUDsg+4jGiwwpDu50KhmbZgiQQ8RB39qQXefTrUjP2ZtJuAit mTuavisBOaMbBbMNMAHJc/y2+owpVYZ0Fx8+pKoh3yBt9uum+nrtn/bYMGg13Xf2EHOC Db5A== X-Gm-Message-State: AOAM532wUR3rY1mjVBjmyrCQYXm6ZPDof0m65D/Fs7x9Fp8M4Uf3D6IE m2TLkPjz1aEbRuw57qBmTn81r6KndYJrzpAxCSs= X-Google-Smtp-Source: ABdhPJy9bfekC1t933fOPbzFYENcQN+eqW+7EGnrnrzBGcNrDj6mBwpdrX+ZIvaajj0sxXWUKj9zyhS/v8ScejPId0A= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f464:6db6:3d47:ed14]) (user=samitolvanen job=sendgmr) by 2002:a25:7901:0:b0:64a:a1d9:43dd with SMTP id u1-20020a257901000000b0064aa1d943ddmr45895436ybc.271.1654904151760; Fri, 10 Jun 2022 16:35:51 -0700 (PDT) Date: Fri, 10 Jun 2022 16:35:08 -0700 In-Reply-To: <20220610233513.1798771-1-samitolvanen@google.com> Message-Id: <20220610233513.1798771-16-samitolvanen@google.com> Mime-Version: 1.0 References: <20220610233513.1798771-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1757; h=from:subject; bh=BzYyCCjIKMVIFOaxytMd//v1RLhPm9T7iP3/4Zx5xVM=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBio9Uusl/O2s6wYiJP/kbTa1chVv26D4F+cGeoouVP CLXe2fiJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYqPVLgAKCRBMtfaEi7xW7p5VC/ 9Ik3mkvkfwpcvMaILAG8ecfZFaAeyupedPFpv7JfK5CDJfRdYJy6I8IwkF6zyaPwEpszbFtzIngJp1 9VLVbi4oBQefo3DpNAVs92FiUcWdUCTKkV7FZtf1KHmTbcXiDaSei1A+sMXqlbWgwS5aukcZ5H+NRj ez76Hc3KoZRoN4iKlxLcKRNHKXpC6fe9Zie7IPO1sMkA1OXATSdGQfVw+6gv4q0+ae1ZMD/7994o7H svydE+m5htCfP8PK65SJBa8zHBM6ew01HQ1rYygo/X2Sc5yi/4w8Z/ysL3lacG7Jweqr21P7GnS2fR EkYD/xUbl9UA4W+IlBSY9HuJiSpiS1MbhICEI2OvNo0BakVlcF8T6rhqcGPF8IKLB7N5SjJnFWHOtd 5iRHPAaDebe6mi//sYNB0DF52K4EuYa7vPMeX54NUVHcDgamHQlZhqAna7cOgDvpSiS34oTlsond2r LOwD6icdz2QqTZkK/eZRy2JwR3ZYdCMaJ91x+ll6SUcLM= X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [RFC PATCH v3 15/20] 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-20220611_003557_322841_A79529E3 X-CRM114-Status: GOOD ( 12.00 ) 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 int3 padding and a mov instruction that embeds the KCFI type identifier in the following format: ; type preamble __cfi_function: int3 int3 mov , %eax int3 int3 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 --- 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 864bb9dd3584..337b92c3b755 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3207,6 +3207,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; @@ -3827,7 +3831,8 @@ static int validate_ibt(struct objtool_file *file) !strcmp(sec->name, "__ex_table") || !strcmp(sec->name, "__jump_table") || !strcmp(sec->name, "__mcount_loc") || - !strcmp(sec->name, "__tracepoints")) + !strcmp(sec->name, "__tracepoints") || + !strcmp(sec->name, ".kcfi_traps")) continue; list_for_each_entry(reloc, &sec->reloc->reloc_list, list)