Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4938435rwi; Mon, 17 Oct 2022 13:00:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Hq7ggFOEWjf+IW/ePZx7vmnDq3lySJTwLEdk8PN+UNnIDIZQ/DIBlEO/bOwM2G9XWNKnF X-Received: by 2002:a05:6a00:10cf:b0:563:34ce:4138 with SMTP id d15-20020a056a0010cf00b0056334ce4138mr14358782pfu.6.1666036846615; Mon, 17 Oct 2022 13:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666036846; cv=none; d=google.com; s=arc-20160816; b=KSCxAGqLGzXA7PcXdO9uKsdhJ6RpmAbDSySQ2jksWa5+2QQRMbDu/pfb37ybwU2Lz1 98PdZK1bMFjER95fgvNfQmsFfTttobJfbtlywxHoaLT2ax/lX9WlGkeF+jV2pweeGDyC LBelg5IZtOjtws5+jh2iY3MUtGh7hWG9JDbKghYMIV/LvWhfEOvzeHfKir0iLNhhY94u FrT02+/ff7zekU5SXqG4GWVyth+2oYHQt64KQ55O+2ObPsFXRWZh7R0ckqowxj3xtDy8 7mu1gYZtT6QSHBM3jYS1Nr2WWMf5zd6KZFeXCgT+7kyEh08qbK1+H/n6DJ5cX0CMwpFT wj5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OgoRbFnaF4liUWHPt9WHRYqaz0KaHrlhSQnzgk41VqE=; b=swZ61ZLpeQXifHXz0CFCpxdMZfB7Ty74IWhMjpQiLKFq6uEeRiFt+uyjLQ1mm3yGb/ 7EFNUchN32lww5sicUefijeGpDlbQmNEZwgYyrCVWeZy28/Lu1QNmMevcPpkk3cGO+vL FbJnTCxW/C9O0Y8Gi9RxhauooVFF9+ATRx5+si2TBsIW/kPUE9u5B8Wkna4nSOiSfyrd Ok5MVacdsld/26EUdqyykmABHKWWIG9ZFHVwuVQ2hx7IkLmvs7zMT5IawOLRrC9MgpLB i9AZxlXaQ9pG+mDxTfPYMcE+J+F/wXxBwg/KKLzJsP3DKnXof0gus2lhUxvgQ3pz8nbO K5aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="GT/v35Lu"; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a17090341c400b0017f92d54633si14912611ple.243.2022.10.17.13.00.32; Mon, 17 Oct 2022 13:00:46 -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=@chromium.org header.s=google header.b="GT/v35Lu"; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbiJQTcx (ORCPT + 99 others); Mon, 17 Oct 2022 15:32:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbiJQTcs (ORCPT ); Mon, 17 Oct 2022 15:32:48 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2EFB13E3E for ; Mon, 17 Oct 2022 12:32:42 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id 67so11992633pfz.12 for ; Mon, 17 Oct 2022 12:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=OgoRbFnaF4liUWHPt9WHRYqaz0KaHrlhSQnzgk41VqE=; b=GT/v35LuZqCPLrxIFCXsGzIq6UX29tB0UKx6j+JPcHBoPfcu4dRDaBTgnhQyQW/4CA u0HRjqYoO06HhlEZ3S+T1lLSJkWrTk1lJcZNZKYhQyU1b6DelWiFNfrDefSd+w+e6RPr CXPqndttYWpUGPY0wRJed9zmFVDXfAAHjI4DU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OgoRbFnaF4liUWHPt9WHRYqaz0KaHrlhSQnzgk41VqE=; b=MivTNr6qRFYBRcl4RaePvuq6bpYpWwdeZ/tx/Bwd0zrppcx2+gEyKv2zloNQNfSXGg P/4NRYSTm0gMJtWQEVQ/igOVGs6gvqfe7d31Vq9BN/+91q9UcpfJPNPAZw6AqWpGC2K2 Y4YOubIW15r+qsKXx+VR/m2KVNnouzLvyImAyjXzYdbMwcRJoEn6L8vRE9IZtHddRcRo 80wlLb4OVWKEwHN2yZCbQSDdnzIEYHuBvZOJ2/z8TnVrSuboGO9eifgLtZCNv15KoKhH gui7LU1f2kHWXI5xiyWdE6D+LtTsc0CB2buu5kfrLalkYgLSDZNHQFwiZmhStfj2zg0h C+lw== X-Gm-Message-State: ACrzQf0N/+GgT/dNhsNG5kHlTBa1wXjjmjSVpHbVMX0K/5KhZIGfE9fw Skwkrsv4Crz5auGPlIwVdIMPLw== X-Received: by 2002:a05:6a00:1145:b0:52b:78c:fa26 with SMTP id b5-20020a056a00114500b0052b078cfa26mr14186864pfm.27.1666035162005; Mon, 17 Oct 2022 12:32:42 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q59-20020a17090a1b4100b001efa9e83927sm9766278pjq.51.2022.10.17.12.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 12:32:40 -0700 (PDT) Date: Mon, 17 Oct 2022 12:32:39 -0700 From: Kees Cook To: Nathan Chancellor Cc: "Li, Xin3" , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" , "H.Peter Anvin" , Peter Zijlstra , llvm@lists.linux.dev, linux-kbuild@vger.kernel.org Subject: Re: upgrade the orphan section warning to a hard link error Message-ID: <202210171230.CC40461C@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 17, 2022 at 11:26:47AM -0700, Nathan Chancellor wrote: > It might be interesting to turn orphan sections into an error if > CONFIG_WERROR is set. Perhaps something like the following (FYI, not > even compile tested)? > > diff --git a/Makefile b/Makefile > index 0837445110fc..485f47fc2c07 100644 > --- a/Makefile > +++ b/Makefile > @@ -1119,7 +1119,7 @@ endif > # We never want expected sections to be placed heuristically by the > # linker. All sections should be explicitly named in the linker script. > ifdef CONFIG_LD_ORPHAN_WARN > -LDFLAGS_vmlinux += --orphan-handling=warn > +LDFLAGS_vmlinux += --orphan-handling=$(if $(CONFIG_WERROR),error,warn) > endif Yes, this is much preferred. > Outright turning the warning into an error with no escape hatch might be > too aggressive, as we have had these warnings triggered by new compiler > generated sections, such as in commit 848378812e40 ("vmlinux.lds.h: > Handle clang's module.{c,d}tor sections"). Unconditionally breaking the > build in these situations is unfortunate but the warnings do need to be > dealt with so I think having it error by default with the ability to > opt-out is probably worth doing. I do not have a strong opinion though. Correct; the mandate from Linus (disregarding his addition of CONFIG_WERROR for all*config builds), is that we should avoid breaking builds. It wrecks bisection, it causes problems across compiler versions, etc. So, yes, only on CONFIG_WERROR=y. -- Kees Cook