From patchwork Wed Dec 13 13:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri John Ledkov X-Patchwork-Id: 177990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7782914dys; Wed, 13 Dec 2023 05:43:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNEL+Vh8QWWmwI+2bK7zXSpeLr/f8798ty5dqN/QJstWusnP0XIyyyx87SYif+4Ss0xXra X-Received: by 2002:a05:6a21:3284:b0:18f:fe5a:8bb7 with SMTP id yt4-20020a056a21328400b0018ffe5a8bb7mr10400495pzb.24.1702475010687; Wed, 13 Dec 2023 05:43:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702475010; cv=none; d=google.com; s=arc-20160816; b=Gf9v7+uk/egxHWhqRpC3sIUWRvS/dz5D1xRLPy2l3G9RjJUrVBxcnp0P9NCCPEAQye tMragexsntvq1POcU8OF9sd3tdJl+anJOv4mHZSSQEhNgPOj3VIW1eEdZYTi6eDHrnRe jaH1cPf15EWWIy+zM6SpBQAnJr4h0WrKdzHAwN0sDaSGkkbaaZItZyRx/x8UBkk01WZD xO6eQSMIt+c7Gc4LIdNOBYFURWd/+BMKQHdQGiW8fXRrazaKg2Na9gc3psK/3tGdvpEr LgZOjfwYgqHxH3bKYrhJXHRcEPePy7jmJOBRei+Z6I1xqfGU92TKHA36IJAHHTXG2kiC 5sgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zGwI2oNuAcGXzDM0lEo9IfpuoUY3xfRn5ssNrL4TUxo=; fh=6ApmiAOj5llZz/5mpFBkruPgBxrXH89XL4qsmxPd28M=; b=u+/r5dhEMDRh2vciqtl8uUbvzUMC7AZtM0xMpBP6gL5Aul/AUodn0xp95cvHJt6ikE WLX7mEbFElEqVwnuRZ5qOTeT0c8adP282jiHrbTBdbUZo8gHtl0K7VIKeZxl2khaNPwW TuqvasAJKdFxRi4Kdwl4ZyUiHySPLF1ieJG/NiM/Enmsj8xjeKqqo9auNJo+SAhn7irA akqhS0jxRbputsu/FRwBimUZMjWhgvFB5Kwk+2oHm3xiEK+Eiz7VbdiceBCoaMEnZJtH GssZiciaHRBEPfg8mvA3PKSEeglh7caWsGK4ELl6E3OwiBvXhJLJbCVX3J+6L0Pd8P8e e09g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=dEtDjiUG; 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=NONE dis=NONE) header.from=canonical.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t5-20020a056a00138500b006bbfc944748si9453042pfg.315.2023.12.13.05.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:43:30 -0800 (PST) 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=@canonical.com header.s=20210705 header.b=dEtDjiUG; 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=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1FC00817DD1F; Wed, 13 Dec 2023 05:43:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233624AbjLMNnM (ORCPT + 99 others); Wed, 13 Dec 2023 08:43:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233465AbjLMNnL (ORCPT ); Wed, 13 Dec 2023 08:43:11 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FB31DC for ; Wed, 13 Dec 2023 05:43:17 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 692393F184 for ; Wed, 13 Dec 2023 13:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702474995; bh=zGwI2oNuAcGXzDM0lEo9IfpuoUY3xfRn5ssNrL4TUxo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dEtDjiUGcGq96oEv9U+z5thFBu1Fe0Wr5GHq6v5URzl2Fq9EdmKynHk5K90GKLMcG WP21Zmvy98Wg30Il666ABynOhAypOCP4O4L2Z0Jj6L2vOkeMkDE8Co95nUgz1V+X9m RdnVWHeHAvebcFqX17AtWLOxUy9AiifFmNFa4qiOlvMQNftOxNw51wbeCq9aPCII9g r30Odrg8Ru0mTb6W7nUm15bpvnWISSrB8z1yo+X/mDap1byKwdeKiYw//Yd5fe/MwC qhfRqGIdAizyvhX8oSSRsFeNOk9KxqTJZa+/aFx7SaKNXiesHP3wc2gJ+GEFbgjd5F aQrxJOE0cio+A== Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40c421f2686so25261285e9.1 for ; Wed, 13 Dec 2023 05:43:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702474995; x=1703079795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zGwI2oNuAcGXzDM0lEo9IfpuoUY3xfRn5ssNrL4TUxo=; b=lPvHcOBdkbxnxxk5eRKdazdrL6yRekVKxZPUppsbO9WqKkPPw6zNduGcmuLSBdIVn8 McPY4f95VQCIflWOI60UTAXT3CUCNAvITWUcBBSfV7jIMw61MmYGp35fRO0nmUktycHu 8BgK8K6pKPcB+ro/6V2+cT5mthIKwH9u9+imnQiC3bui4WNyIOX5uP00vmO5Vmw925r8 aT7QDWm9IeGrzHaIF0/KfWd3OcIun57JNBMOlm/FAsxfOhCb6vg0AHasmIeUOuL455fS NWPtzecHkQRQ98EgHwBMvwTYRuds3C8gtFtWnTuCJSf2AKnvPs+I0SR4oYPWRgkWdCyT N2+A== X-Gm-Message-State: AOJu0YxULII1Gcvhj3aQ4k6LtNDnDpWv2hvPWR/j81MZ3Ow6KVPxbI7H B1A4ymxQKyJl3L2pQ3K+VV54uZcJPVRpR7LQW8e2DauEImkn3hiSL9LDFmd9IDzbzmddqy/Z/Sg F7ZTqwUMluxAUk1Lz96d+RWpRtiB7ZiuwAxkBusASxQ== X-Received: by 2002:a05:600c:3146:b0:40c:3e8b:8672 with SMTP id h6-20020a05600c314600b0040c3e8b8672mr1709085wmo.132.1702474995049; Wed, 13 Dec 2023 05:43:15 -0800 (PST) X-Received: by 2002:a05:600c:3146:b0:40c:3e8b:8672 with SMTP id h6-20020a05600c314600b0040c3e8b8672mr1709078wmo.132.1702474994694; Wed, 13 Dec 2023 05:43:14 -0800 (PST) Received: from localhost ([2001:67c:1560:8007::aac:c15c]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c190800b0040c58e410a3sm3236396wmq.14.2023.12.13.05.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:43:14 -0800 (PST) From: Dimitri John Ledkov To: jpoimboe@kernel.org, peterz@infradead.org Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] objtool: Make objtool check actually fatal upon fatal errors Date: Wed, 13 Dec 2023 13:43:00 +0000 Message-Id: <20231213134303.2302285-2-dimitri.ledkov@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213134303.2302285-1-dimitri.ledkov@canonical.com> References: <20231213134303.2302285-1-dimitri.ledkov@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: 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]); Wed, 13 Dec 2023 05:43:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785174437177705362 X-GMAIL-MSGID: 1785174437177705362 Currently function calls within check() are sensitive to fatal errors (negative return codes) and abort execution prematurely. However, in all such cases the check() function still returns 0, and thus resulting in a successful kernel build. The only correct code paths were the ones that escpae the control flow with `return ret`. Make the check() function return `ret` status code, and make all negative return codes goto that instruction. This makes fatal errors (not warnings) from various function calls actually fail the build. E.g. if create_retpoline_sites_sections() fails to create elf section pair retpoline_sites the tool now exits with an error code. Signed-off-by: Dimitri John Ledkov --- tools/objtool/check.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index e94756e09c..15df4afae2 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4669,166 +4669,163 @@ static void free_insns(struct objtool_file *file) int check(struct objtool_file *file) { int ret, warnings = 0; arch_initial_func_cfi_state(&initial_func_cfi); init_cfi_state(&init_cfi); init_cfi_state(&func_cfi); set_func_state(&func_cfi); init_cfi_state(&force_undefined_cfi); force_undefined_cfi.force_undefined = true; - if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) + if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) { + ret = -1; goto out; + } cfi_hash_add(&init_cfi); cfi_hash_add(&func_cfi); ret = decode_sections(file); if (ret < 0) goto out; warnings += ret; if (!nr_insns) goto out; if (opts.retpoline) { ret = validate_retpoline(file); if (ret < 0) - return ret; + goto out; warnings += ret; } if (opts.stackval || opts.orc || opts.uaccess) { ret = validate_functions(file); if (ret < 0) goto out; warnings += ret; ret = validate_unwind_hints(file, NULL); if (ret < 0) goto out; warnings += ret; if (!warnings) { ret = validate_reachable_instructions(file); if (ret < 0) goto out; warnings += ret; } } else if (opts.noinstr) { ret = validate_noinstr_sections(file); if (ret < 0) goto out; warnings += ret; } if (opts.unret) { /* * Must be after validate_branch() and friends, it plays * further games with insn->visited. */ ret = validate_unrets(file); if (ret < 0) - return ret; + goto out; warnings += ret; } if (opts.ibt) { ret = validate_ibt(file); if (ret < 0) goto out; warnings += ret; } if (opts.sls) { ret = validate_sls(file); if (ret < 0) goto out; warnings += ret; } if (opts.static_call) { ret = create_static_call_sections(file); if (ret < 0) goto out; warnings += ret; } if (opts.retpoline) { ret = create_retpoline_sites_sections(file); if (ret < 0) goto out; warnings += ret; } if (opts.cfi) { ret = create_cfi_sections(file); if (ret < 0) goto out; warnings += ret; } if (opts.rethunk) { ret = create_return_sites_sections(file); if (ret < 0) goto out; warnings += ret; if (opts.hack_skylake) { ret = create_direct_call_sections(file); if (ret < 0) goto out; warnings += ret; } } if (opts.mcount) { ret = create_mcount_loc_sections(file); if (ret < 0) goto out; warnings += ret; } if (opts.prefix) { ret = add_prefix_symbols(file); if (ret < 0) - return ret; + goto out; warnings += ret; } if (opts.ibt) { ret = create_ibt_endbr_seal_sections(file); if (ret < 0) goto out; warnings += ret; } if (opts.orc && nr_insns) { ret = orc_create(file); if (ret < 0) goto out; warnings += ret; } free_insns(file); if (opts.verbose) disas_warned_funcs(file); if (opts.stats) { printf("nr_insns_visited: %ld\n", nr_insns_visited); printf("nr_cfi: %ld\n", nr_cfi); printf("nr_cfi_reused: %ld\n", nr_cfi_reused); printf("nr_cfi_cache: %ld\n", nr_cfi_cache); } out: - /* - * For now, don't fail the kernel build on fatal warnings. These - * errors are still fairly common due to the growing matrix of - * supported toolchains and their recent pace of change. - */ - return 0; + return ret < 0 ? ret : 0; } From patchwork Wed Dec 13 13:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri John Ledkov X-Patchwork-Id: 177991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7782940dys; Wed, 13 Dec 2023 05:43:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHv0jhvKD0jPFCIapCd9Up2faspIANXFR9FigO6+kdq42hgigWCjqCW50AzX//KzpQTiiq X-Received: by 2002:a05:6a20:5648:b0:18c:a9d3:c363 with SMTP id is8-20020a056a20564800b0018ca9d3c363mr3777440pzc.41.1702475011638; Wed, 13 Dec 2023 05:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702475011; cv=none; d=google.com; s=arc-20160816; b=AN5QA+zcMNLG6r4wJ0vSnceMdM4QU5zACunQyoXEWvA0hwRtvHovR/tSv+vOOVrR5i IRCFsNSoVeRaghvpm3EbIqgDuhwH3AW+oYgnYoTPRM2nOijZi/CLsAMoaP1nJTK1HMVc ItVN3+bKztQAI2YGMNA7R9d7fJ7SnzW4txyliXt/3BWB6NgGjjvyTvPp5lEkEG4bwYag jmPfpYkZbXwfBm/KeuapXT35/aK2qP/pu7sS9tEYKFXby+qccil4jeQ0kM+DdkBLJABk i04L6vJN09CSv6x5TEaGflODmFtA2HRYzFk1deioX1y1T3pR5hhuXGGgLzFlk7g9TR81 HIqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i0Esn9+nyWOVkq+Y2H+yWu8DGPZPCcolJEjwYdbl1Tg=; fh=6ApmiAOj5llZz/5mpFBkruPgBxrXH89XL4qsmxPd28M=; b=WCfC5Imu0avzrJRtQDfDLA8fwL248KWhZtc+u/o25nsk3sMjPyw0TSuhv3a3ED3L29 UphRrNfbL4lr1YMlTPqVr0WRCovi5xHOPRFtxDuydNXxNSx2NlZJfSdvV9bvoYV/79Xk i8w8BAfgxilCQ5ewzA9J1GQMjgGKOyWnOl0O/Rfwbu50Bb+dfDJ7/Du21WlS8wSbOADf RgPBLdRWnzfR7yhKn+iLo2fkjITrU3Ju2TFjIZbZPc/FpkCJchgFjIFopyyH9XV70CFL HbZAhUpO3N3B8+hceqgpPDgcLvvYPK4bOf+VvsQzqt2yCw24T82PMXr9qQaJJsGClo6b 2bxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=s3Wgs4aM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c5-20020aa78c05000000b006ce08cdaf39si9485072pfd.386.2023.12.13.05.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:43:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=s3Wgs4aM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0072180A07CA; Wed, 13 Dec 2023 05:43:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378881AbjLMNnO (ORCPT + 99 others); Wed, 13 Dec 2023 08:43:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235361AbjLMNnN (ORCPT ); Wed, 13 Dec 2023 08:43:13 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB1D9C for ; Wed, 13 Dec 2023 05:43:19 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8F5A63F285 for ; Wed, 13 Dec 2023 13:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702474997; bh=i0Esn9+nyWOVkq+Y2H+yWu8DGPZPCcolJEjwYdbl1Tg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s3Wgs4aMkj0jKO4Lrlsy09wGAr77iAf1TN984PgjKAB8kdUfYSAf+EUiO0Mzxcryu jd5Ri/IMGOOYwOUcq1As3K/GgZgz+l1LYxUsPo3zgNGt6hDp6mgYSgU9iWeZx4oqe6 y1y5FIAdYgQFXjCKna3JJsqhNRYcmdHS7YZSBV6RtnNzC49W/zjonQ89/10jO+byO1 Dq2eSTjKSUhJV9WjOQ9muEUxAoHXexmPPb3pd+1J9YNz6xuUwRDWsISyUqroaqN6xK A4tSmh12mQ+xLr3ESSELF52v0BPrGWj+y5m5CryP285GA97KhJQkKhxkL24e/8zBpc ijL6Us2dnWDtw== Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40c2c568108so45062155e9.1 for ; Wed, 13 Dec 2023 05:43:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702474997; x=1703079797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i0Esn9+nyWOVkq+Y2H+yWu8DGPZPCcolJEjwYdbl1Tg=; b=aVEBFeND236MtR8MbpnytR0jDJ0KgCTHLXSMjEDDmhti4QBVos3lk82iyRy6+LXh1f voj2kLzO3n1jXH0kKWxuGl7dHxRioBSxppYiMwcvQcFeqNpcZr8pLyAGx/wtoB74fqy4 mixkjEFkUGfGWS5F2Qa7xJ3x1MilAnHaIstUBoCZc2RfnFbQKEX0sIstY0vzZor/wt0N Z16q6Ntjwf29YLVP69ClRkNxqwhLSAR3nG3qJM/IGNbypSMkLracnNWf+NMiil+2IIGt ffYMuGQKy0Vsn46XXU/dapH5XKNuW0BuyHUAMA/ZG0v20WMH10Y4u88gPiMIJxfSctzy HKWQ== X-Gm-Message-State: AOJu0YwQ3Gk/haNkydIr+NYOp6tj2fmaQy4CIIuRLIcLy2uOr7JqYkhu sHBpMoDzKP5I5BlW5d6GlH3UDHFn3hIIaBXASJGxIkZsi9XmlGe3/VkMUPJxAyAYl+n/NAc95kn A/YcyCSm0oEVqCVqh+znmX8vehKeVTAl0NBcvavWWQQ== X-Received: by 2002:a05:600c:2a8d:b0:40c:3308:3afd with SMTP id x13-20020a05600c2a8d00b0040c33083afdmr3802894wmd.12.1702474997275; Wed, 13 Dec 2023 05:43:17 -0800 (PST) X-Received: by 2002:a05:600c:2a8d:b0:40c:3308:3afd with SMTP id x13-20020a05600c2a8d00b0040c33083afdmr3802888wmd.12.1702474997036; Wed, 13 Dec 2023 05:43:17 -0800 (PST) Received: from localhost ([2001:67c:1560:8007::aac:c15c]) by smtp.gmail.com with ESMTPSA id jb4-20020a05600c54e400b0040c5cf930e6sm1982346wmb.19.2023.12.13.05.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:43:16 -0800 (PST) From: Dimitri John Ledkov To: jpoimboe@kernel.org, peterz@infradead.org Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] objtool: make objtool SLS validation fatal when building with CONFIG_SLS=y Date: Wed, 13 Dec 2023 13:43:01 +0000 Message-Id: <20231213134303.2302285-3-dimitri.ledkov@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213134303.2302285-1-dimitri.ledkov@canonical.com> References: <20231213134303.2302285-1-dimitri.ledkov@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:43:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785174437763550331 X-GMAIL-MSGID: 1785174437763550331 Make objtool SLS validation fatal when building with CONFIG_SLS=y, currently it is a build.log warning only. This is a standalone patch, such that if regressions are identified (with any config or toolchain configuration) it can be reverted until relevant identified code is fixed up or otherwise ignored/silecned/marked as safe. Signed-off-by: Dimitri John Ledkov --- tools/objtool/check.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 15df4afae2..9709f037f1 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4500,7 +4500,9 @@ static int validate_sls(struct objtool_file *file) } } - return warnings; + /* SLS is an optional security safety feature, make it fatal + * to ensure no new code is introduced that fails SLS */ + return -warnings; } static bool ignore_noreturn_call(struct instruction *insn) From patchwork Wed Dec 13 13:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri John Ledkov X-Patchwork-Id: 177992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7782973dys; Wed, 13 Dec 2023 05:43:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdRS/GEH1Rk3ziNRJAXs4Nop1FTRKid2xHfn0nzIGJO8nvYj2udFteNIoyzypWEk6Fe+WY X-Received: by 2002:a05:6a20:244f:b0:18f:f040:86df with SMTP id t15-20020a056a20244f00b0018ff04086dfmr8662770pzc.82.1702475016441; Wed, 13 Dec 2023 05:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702475016; cv=none; d=google.com; s=arc-20160816; b=i1n4S0Yoa3xXqZof/IxpyLqW6ClTT6d5zwEI8LGmtskAcoFargtME6ywvuTKgMKy1p /wbrQtyH2TNZ7phvZ924YKamgnZ8/yquAL46zzQI29Moe+ieo3Sf6H3MLYklcNpw1pDO gdQIcgVh2nSSzBU/1oQoE39f0rj86Toi6kYdGGTjuoxW+W3E0YqLv+n85/Y0pl/j6f/w /qzdcZbRiQbTJdb0OCz0442bLZ3pP0vdPHVvKiHO3FGSNC5MtgvWEz/pn+yQsBHmsTzX cSTPqX9JnhBLVFGNQoq6wNi18HRPBou588ojkGfhkt2uzJl4w+7VpKi2RGUgkZnbISLv 1Ocg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uM/Cfv1vwzgbhYkByR9B4hJJ+cVjQnEklsojPpuPdXQ=; fh=6ApmiAOj5llZz/5mpFBkruPgBxrXH89XL4qsmxPd28M=; b=u6S0w7uFl1g4v72UU3q18e49mdbebHbOxtXjOeqIRTeZDoC22zM0jUmQwoJGc3z9gG DKSm6D1h5HJs+0taWHBznq78FpUmtrA4ZjXtG+pfRn6kdUOB2FgFPbp9o8gBQllRBcsG gt6S25nK50k6H0oonx+EgFzciVwg2PtNl3dPmG7R7zgm/EZK/RIdXcRKjVHtFRmTpqgP GXCwJt/sWTkCvWOl/kZCzjm8bznxHN3UBlQce39jj182+ZjQFMbgdd1BOIc1Iuy6aCMb 1g2g4sazLqtNGiKK8LYkiauNa0wGUAa7L7s3SpHKbdr3O39PNNxAgMNYcojeHlYxfU+V txEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=VsHIRli2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 6-20020a630f46000000b00578b487825asi9481950pgp.208.2023.12.13.05.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:43:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=VsHIRli2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B560E822A489; Wed, 13 Dec 2023 05:43:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233465AbjLMNnR (ORCPT + 99 others); Wed, 13 Dec 2023 08:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378905AbjLMNnQ (ORCPT ); Wed, 13 Dec 2023 08:43:16 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98017AB for ; Wed, 13 Dec 2023 05:43:22 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 740EA3F285 for ; Wed, 13 Dec 2023 13:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702475001; bh=uM/Cfv1vwzgbhYkByR9B4hJJ+cVjQnEklsojPpuPdXQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VsHIRli2pTZ6iIHCW3eYbOklT6g0gh2Lmd/wP9FUSZ2MDM34SoQUaLr61X4oBJtE7 TNj47ViVyI+OnRpNH4JSHiel6hRUn+hnZ1zA7ZAKKtMC4GF+RChKii5yuJRmX5WyVx 7mNz0u+YYOTEVqPbV8SEwiNGEs9Uq1rpWbNwQFqA0gHQL2BV+7l/QGXV9a8hFZ+Yyo vXFOFxH8USjsIlUxq+B9/dDwyByPVgs2qGCDGMRRwlItjxnNaQkws+V5trYU8W2+k+ 6VfXGidyVkjQtoc5rBm9/kCKT9FAqow20BXDTunvP1UZm2ihM6bFIU2UtK96oIdsSO pWTG7pbdv3CZw== Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40c3826d6feso30999575e9.0 for ; Wed, 13 Dec 2023 05:43:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702475000; x=1703079800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uM/Cfv1vwzgbhYkByR9B4hJJ+cVjQnEklsojPpuPdXQ=; b=Q57JX2mhQtHhG9965TqbQOZMVUaYUBXboUn25l2IpBfNKjQhdxmcvgKIIVCY/4i3Bt xA2BX+TVq1zHAal6pvzemrjtJPfWslx3NDRmuuf0n35+Zq88/A4woz54fgo34rtkob4Q 6F3k3iLTLhjq9DdaWJNjXm6e0ZzqrjeGwKSqsxNwy722lscuGs+54St07+cipcG5pAtS T/Z4sqophiqBi8HgNOVmhFT5ZT3v1xPSb9OZu/AzC1zVeOvsP8Zh3/u2/6uyB4f1zogt 5MbU0fkzwvVb1RnIKzTpmFqKWpjZPN1/CKgJmII5dhKbcYXkEu220hpmR+2E8JXdBacT bl4Q== X-Gm-Message-State: AOJu0YxIAa/Z9dbNX/420LPZ7IsXJJBjg21oiXFHee93AgjHCqDGgEYb bJkuFeeoStMo3tYry4sC7iOBsxisJw0/W8i8Lg60jYtN9jqKCp5pry9YjF8Yls/tkVhCfOCsuCp ckBrbSIhlROUFsh3dyCYGUVzJJhHJ1aRXzswyGc3O5EOg3P5HfQ== X-Received: by 2002:a05:600c:ac8:b0:40b:5e1b:549e with SMTP id c8-20020a05600c0ac800b0040b5e1b549emr4130203wmr.42.1702475000494; Wed, 13 Dec 2023 05:43:20 -0800 (PST) X-Received: by 2002:a05:600c:ac8:b0:40b:5e1b:549e with SMTP id c8-20020a05600c0ac800b0040b5e1b549emr4130191wmr.42.1702475000108; Wed, 13 Dec 2023 05:43:20 -0800 (PST) Received: from localhost ([2001:67c:1560:8007::aac:c15c]) by smtp.gmail.com with ESMTPSA id h12-20020a05600c314c00b0040c45cabc34sm12197042wmo.17.2023.12.13.05.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:43:19 -0800 (PST) From: Dimitri John Ledkov To: jpoimboe@kernel.org, peterz@infradead.org Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] objtool: make objtool RETPOLINE validation fatal when building with CONFIG_RETPOLINE=y Date: Wed, 13 Dec 2023 13:43:02 +0000 Message-Id: <20231213134303.2302285-4-dimitri.ledkov@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213134303.2302285-1-dimitri.ledkov@canonical.com> References: <20231213134303.2302285-1-dimitri.ledkov@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:43:33 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785174442759542578 X-GMAIL-MSGID: 1785174442759542578 Make objtool RETPOLINE validation fatal when building with CONFIG_RETPOLINE=y, currently it is a build.log warning only. This is a standalone patch, such that if regressions are identified (with any config or toolchain configuration) it can be reverted until relevant identified code is fixed up or otherwise ignored/silecned/marked as safe. Signed-off-by: Dimitri John Ledkov --- tools/objtool/check.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 9709f037f1..c21258e109 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3991,7 +3991,10 @@ static int validate_retpoline(struct objtool_file *file) warnings++; } - return warnings; + /* RETPOLINE is an optional security safety feature, make it + * fatal to ensure no new code is introduced that fails + * RETPOLINE */ + return -warnings; } static bool is_kasan_insn(struct instruction *insn)