From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2800C433E0 for ; Wed, 24 Jun 2020 15:36:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2A4E2076E for ; Wed, 24 Jun 2020 15:36:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="L87UOx1r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404230AbgFXPgZ (ORCPT ); Wed, 24 Jun 2020 11:36:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404193AbgFXPgX (ORCPT ); Wed, 24 Jun 2020 11:36:23 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD67C061573 for ; Wed, 24 Jun 2020 08:36:22 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id t6so1602128pgq.1 for ; Wed, 24 Jun 2020 08:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XJUzgH5TgVAKrlAz/oLGoEzf+4q4DR2SPe5g3v8Hoz0=; b=L87UOx1rFbEBv6EAXMjq42JQm86UtPUvAjrSDFUjZV7/S2Fdwtz80FtkbJzD8kccUr iRuRTc98qsUUvW4wRLaZIRPNfFKjSXe1ODNggmES4VHyXOVp9NEfQINR136Asyjj1o/J v+lhjyzt2oK0bGeFeFUl+FR9FpGwVWyk6cXTQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XJUzgH5TgVAKrlAz/oLGoEzf+4q4DR2SPe5g3v8Hoz0=; b=H5vDnsHhbk2GHh7+IoA4u469BCrZ1OOlOwc5mFajjJ4RnXDf+ouFs+ZIkAkW1pc64p 3ABL0COq3jIzfxwx3mNywbz+antxl/4rPTQ7iSuWzU0j1Ts8GVV8RTjHsVUxLmcQNf/t 5joWE/kKXlX99w7YSDCAL1ZkUNG+Ns3V/hZtAd/u0aDdv+VjG6WNXf3TH+eI0PEpu/zL 9pDDCHaH9+03Ep/EsaQK5k07akHBFkNOvFPvRpqcdKNPn8hwIoOOz4AEZcQ2TgnVfqXH jUve0Tak8eHu/o+b9wYFwtCU0iT4FngrU4FGM+1w3RZg2khnD24dYhVHuTvi217CGsoE pi+g== X-Gm-Message-State: AOAM531MPrIeDL/RjfO6/fozIiqCJRXmEv5lqznkrvCcyvCScRX1nvIl lUoasZNYN6tYvYS5VqmNqYE7uA== X-Google-Smtp-Source: ABdhPJzh0NIgxXcoqTxHGxMf5jIULfS15W7YCEH1YCRk0fdSR5z7SraN22S3afSROtaHxZ0aAd1AOA== X-Received: by 2002:a63:aa42:: with SMTP id x2mr21604671pgo.361.1593012982182; Wed, 24 Jun 2020 08:36:22 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j36sm17984549pgj.39.2020.06.24.08.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:36:21 -0700 (PDT) Date: Wed, 24 Jun 2020 08:36:20 -0700 From: Kees Cook To: Will Deacon Cc: Catalin Marinas , Mark Rutland , Ard Biesheuvel , Peter Collingbourne , James Morse , Borislav Petkov , Thomas Gleixner , Ingo Molnar , Russell King , Masahiro Yamada , Arvind Sankar , Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , x86@kernel.org, clang-built-linux@googlegroups.com, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 9/9] arm64/build: Warn on orphan section placement Message-ID: <202006240835.E474048BBF@keescook> References: <20200624014940.1204448-1-keescook@chromium.org> <20200624014940.1204448-10-keescook@chromium.org> <20200624075712.GB5853@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200624075712.GB5853@willie-the-truck> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 08:57:12AM +0100, Will Deacon wrote: > On Tue, Jun 23, 2020 at 06:49:40PM -0700, Kees Cook wrote: > > We don't want to depend on the linker's orphan section placement > > heuristics as these can vary between linkers, and may change between > > versions. All sections need to be explicitly named in the linker > > script. > > > > Avoid .eh_frame* by making sure both -fno-asychronous-unwind-tables and > > -fno-unwind-tables are present in both CFLAGS and AFLAGS. Remove one > > last instance of .eh_frame by removing the needless Call Frame Information > > annotations from arch/arm64/kernel/smccc-call.S. > > > > Add .plt, .data.rel.ro, .igot.*, and .iplt to discards as they are not > > actually used. While .got.plt is also not used, it must be included > > otherwise ld.bfd will fail to link with the error: > > > > aarch64-linux-gnu-ld: discarded output section: `.got.plt' > > > > However, as it'd be better to validate that it stays effectively empty, > > add an assert. > > > > Explicitly include debug sections when they're present. > > > > Fix a case of needless quotes in __section(), which Clang doesn't like. > > > > Finally, enable orphan section warnings. > > > > Thanks to Ard Biesheuvel for many hints on correct ways to handle > > mysterious sections. :) > > Sorry to be a pain, but this patch is doing 3 or 4 independent things at > once. Please could you split it up a bit? > e.g. > > - Removal of cfi directives from smccc macro > - Removal of quotes around section name for clang > - Avoid generating .eh_frame > - Ensure all sections are accounted for in linker script and warn on orphans > > That way it's a bit easier to manage, we can revert/backport bits later if > necessary and you get more patches in the kernel ;) Yeah, this one patch did grow a bit. ;) I've split it up now. > You can also add my Ack on all the patches: > > Acked-by: Will Deacon Thanks! -- Kees Cook