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=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable 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 EC9E1C433E0 for ; Thu, 18 Mar 2021 19:29:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EB6A64F24 for ; Thu, 18 Mar 2021 19:29:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EB6A64F24 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qIVIZlfTcAwH4EYpsCYCLxVXJhBKQnPo55nOoFgSsfk=; b=C5gT6r81+BTfOQzNvo6F0MVvq +dD4QHHrK92FrHpoOX1eEM7v7L4mi//CGYDEIzkNEqtlgODj5dSJDuLZ9eD7+mNRCIwpSLXd7ZZZV AO6tbNuDEU+3+/NZhoAswT4gUkPRQarNwPOB1tqOhJMmz/nTQS0Oq6VsPiNTwetMWYEcUSp9Fmal2 B0mHRISARInMak7QWW4MxBBO7d6rS0RiHDHHd174SrUwXVmtHHd23GL527U2w5Kl7eRnjQKcXWbgs 0KQ85l84jobOdtUNaLpP6VCXc3ZuqOuBhzGHTsDmZQpuY21TAcsTN8HEXjbJ74L6/b2zF3M5j33as 6NuoEC55A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMyJP-005wDL-0h; Thu, 18 Mar 2021 19:28:03 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMyJK-005wD0-Ls for linux-arm-kernel@lists.infradead.org; Thu, 18 Mar 2021 19:28:01 +0000 Received: by mail-lf1-x134.google.com with SMTP id j11so6353731lfg.12 for ; Thu, 18 Mar 2021 12:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fspya4XBtFR7Kjia5AOXCu2vMjqacQ/eg21hgvTyIiA=; b=V0zGJmtjfeUxAzYW2JbBAD59Y6NFskvJjGprJjF5sRu1F7yND0V/Ocx2wCviLvTJqS 2iwD++kbQJ8uatls/4I4kAMuA5pliKsV0PGcuKvjtjimeorSf7fD/SyrkWSG6LaU9kFp uOqEA6rQcj02QEEz565bO3ofLdjyfKvBy6chVF2qpDpm9ctaVp5XaZJt2kCHru35NhPC 6t0Wk+Kp6RuXDHNUr/Xdfi4KhAr334sWMxO7Ci4gVb01vkBuSI20u0lzzrm8VOgYkNh3 bPG/VCgWtabQQ1lP/K4RMFSESYslBiEH2U243vQuv7EPAAG9aCWRBl8QnhlceiFUwWoK MIag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fspya4XBtFR7Kjia5AOXCu2vMjqacQ/eg21hgvTyIiA=; b=NEzO9KQgX/e+HGd+ax5Kcf4TSrcejJEZw5oqqAGegoXOcnghSCPlBwa7+uSbQtz9eR n00fzHPVyxFPb5ROaIjS0EVVLR6ClhHjzq/mgbmNeol/tEjQCIMLmQHExif1/l8QmQ57 k4FImvFkM/j2P3kDeRwwxkGIprBR3COuKs3yi/D7h7BAxcLC3Yt7UgMrBL1zE+sihStD QMm2NXGCB8uXOUgAsciru67w1ePXJhj3XYAsjRY2Thq52uniBfo44NHTDoxYDDvKZIlc XTKwt3cU3iAc2lzyPUv+MxzxahBwlGnHziRe5Ot8bR65d6QAerzsQYEkazYMgTGkkbrT 05xw== X-Gm-Message-State: AOAM5334xR3Dhh5Y8Voggt1MNVTui/pa/jOVqC97L9HV6y9gmkdccB/s hVBa0Q7CRsx3L+5H66Edn7w0tY+dCsNYCOAYEdNHug== X-Google-Smtp-Source: ABdhPJweTgo1kbO051P2mdlKBZSgkmABnh4OQ7GaD+B5jCTTrQXCv4+NpbYAUz7Wi1fnX1PvZh2MNc08DzjnXvFdNNk= X-Received: by 2002:a05:6512:94d:: with SMTP id u13mr4465444lft.368.1616095674888; Thu, 18 Mar 2021 12:27:54 -0700 (PDT) MIME-Version: 1.0 References: <20210318171111.706303-1-samitolvanen@google.com> <20210318171111.706303-5-samitolvanen@google.com> In-Reply-To: <20210318171111.706303-5-samitolvanen@google.com> From: Nick Desaulniers Date: Thu, 18 Mar 2021 12:27:43 -0700 Message-ID: Subject: Re: [PATCH v2 04/17] module: ensure __cfi_check alignment To: Sami Tolvanen Cc: Kees Cook , Nathan Chancellor , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Christoph Hellwig , bpf , linux-hardening@vger.kernel.org, linux-arch , Linux ARM , Linux Kbuild mailing list , PCI , LKML X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210318_192759_018003_681A662C X-CRM114-Status: GOOD ( 24.47 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Mar 18, 2021 at 10:11 AM Sami Tolvanen wrote: > > CONFIG_CFI_CLANG_SHADOW assumes the __cfi_check() function is page > aligned and at the beginning of the .text section. While Clang would > normally align the function correctly, it fails to do so for modules > with no executable code. > > This change ensures the correct __cfi_check() location and > alignment. It also discards the .eh_frame section, which Clang can > generate with certain sanitizers, such as CFI. > > Link: https://bugs.llvm.org/show_bug.cgi?id=46293 > Signed-off-by: Sami Tolvanen > --- > scripts/module.lds.S | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/scripts/module.lds.S b/scripts/module.lds.S > index 168cd27e6122..93518579cf5d 100644 > --- a/scripts/module.lds.S > +++ b/scripts/module.lds.S > @@ -3,10 +3,19 @@ > * Archs are free to supply their own linker scripts. ld will > * combine them automatically. > */ > +#include > + > +#ifdef CONFIG_CFI_CLANG > +# define ALIGN_CFI ALIGN(PAGE_SIZE) > +#else > +# define ALIGN_CFI > +#endif > + > SECTIONS { > /DISCARD/ : { > *(.discard) > *(.discard.*) > + *(.eh_frame) Do we want to unconditionally discard this section from modules for all arches/configs? I like how we conditionally do so on SANITIZER_DISCARDS in include/asm-generic/vmlinux.lds.h for example. > } > > __ksymtab 0 : { *(SORT(___ksymtab+*)) } > @@ -40,7 +49,14 @@ SECTIONS { > *(.rodata..L*) > } > > - .text : { *(.text .text.[0-9a-zA-Z_]*) } > + /* > + * With CONFIG_CFI_CLANG, we assume __cfi_check is at the beginning > + * of the .text section, and is aligned to PAGE_SIZE. > + */ > + .text : ALIGN_CFI { > + *(.text.__cfi_check) > + *(.text .text.[0-9a-zA-Z_]* .text..L.cfi*) > + } > } > > /* bring in arch-specific sections */ > -- > 2.31.0.291.g576ba9dcdaf-goog > -- Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel