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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 C46DFC4708F for ; Wed, 2 Jun 2021 19:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0879613EA for ; Wed, 2 Jun 2021 19:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbhFBTfl (ORCPT ); Wed, 2 Jun 2021 15:35:41 -0400 Received: from mail-pl1-f169.google.com ([209.85.214.169]:42639 "EHLO mail-pl1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbhFBTfh (ORCPT ); Wed, 2 Jun 2021 15:35:37 -0400 Received: by mail-pl1-f169.google.com with SMTP id v13so1623067ple.9 for ; Wed, 02 Jun 2021 12:33:41 -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=4e1fH+i/4Nf38IYF0J8GBj+xdjCqFkdwdWN2L+YElMY=; b=Ne32eZA/sGKOBjJXF16uA1Y7T7rMhnXh2Ziva3sUZQP7FIVtan8BXlbrdVQNOmpa4p mo/McA3nj5bdJ8g+VPCr8ob3beUa2nLTODFoxdssvqecrarIo41wLITRf0AJXYuPjaQ1 ue/xanHzLqGBHkNJaokCOOu1NKQaUL25OIc0E= 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=4e1fH+i/4Nf38IYF0J8GBj+xdjCqFkdwdWN2L+YElMY=; b=dc7AGA/JC1XatcqtlccScAkDlXlMgwrAL6CVPXyyhmnMhOiIxhvGcFd/hKNqmMNbI8 npwhEyRAr7q6SzY2HfB5aDm4icNTnIx99X733KkdsohRZxuJs4IftZ3yul4rp3q3MLgi N/Nij/aNO+SAQx+FZsGct0s0/otEi9JjUFc2OSq9HR7VUgOv1LHQvE+p6O/Fp24FM0eC zj4WMoOFM2wFTipkiEVkaY7b8krrXiKeOqGQuxVz6BGjbJr1l3lgZ2Ht6WAczFzw+C8P E/97mSobAwXP64Ln9kTNUWvLF3wBLbk454i5h7ffAWDM45hEk23Q51NPYhtGgjDylPat lbDQ== X-Gm-Message-State: AOAM531c/iSAQritgxw0iegoIyYrrNqffzqUXSoACciMiDkiGOrxfKG6 ZAX13GU7mv1w7kzgyZy67e8MVQ== X-Google-Smtp-Source: ABdhPJzjgGtjqvUgiVc2BReU2BmJawBbl2m8YPOEjnFEOGPI2Ik7hFRqbL7Rng0mBo3lXOCsMHkAfQ== X-Received: by 2002:a17:90a:f304:: with SMTP id ca4mr27502271pjb.177.1622662361679; Wed, 02 Jun 2021 12:32:41 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u23sm31828pgk.38.2021.06.02.12.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 12:32:41 -0700 (PDT) Date: Wed, 2 Jun 2021 12:32:40 -0700 From: Kees Cook To: Catalin Marinas Cc: Arnd Bergmann , Fangrui Song , Will Deacon , Ard Biesheuvel , Mark Rutland , Marc Zyngier , David Brazdil , Linux ARM , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section Message-ID: <202106021231.A1B7A10@keescook> References: <20210226140352.3477860-1-arnd@kernel.org> <202102261256.AF256702@keescook> <20210227043257.k3aernmnzsvitp7c@google.com> <20210316104530.GA7309@arm.com> <20210316162745.GA20565@arm.com> <20210316190921.GB28565@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210316190921.GB28565@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 07:09:23PM +0000, Catalin Marinas wrote: > On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote: > > On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas wrote: > > > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote: > > > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote: > > > > > On 2021-02-26, Kees Cook wrote: > > > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote: > > > > > > > From: Arnd Bergmann > > > > > > > > > > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, > > > > > > > I sometimes see an assertion > > > > > > > > > > > > > > ld.lld: error: Entry trampoline text too big > > > > > > > > > > > > Heh, "too big" seems a weird report for having it discarded. :) > > > > > > > > > > > > Any idea on this Fangrui? > > > > > > > > > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 ) > > > > > > > > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds > > > > > > > > > > ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16), > > > > > "Entry trampoline text too big") > > > > > > > > Can we not change the ASSERT to be <= PAGE_SIZE instead? > > > > > > Ah, that won't work as I suspect we still need the trampoline section. > > > > > > Arnd, do you know why this section disappears? I did a simple test with > > > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is > > > still around. > > > > If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE > > is disabled, which dropped the only reference into this section. > > If that doesn't make sense, I can try digging through the old build logs to > > reproduce the problem. > > I suspected this as well but still worked for me when disabling it. > > Anyway, I don't think identifying the exact option is necessary. With > CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only > __entry_tramp_text_start/end are referenced. > > In this case we happened to detect this issue because of the ASSERT in > vmlinux.lds.S but I wonder what else the linker drops with this dead > code elimination that we may not notice (it seems to remove about 500KB > from the resulting image in my test). > > I'll push these two patches to -next for wider coverage before deciding > on mainline (though the option may not get much testing as it's hidden > behind EXPERT and default n). I don't see this in -next? Catalin, do you want me to pick it up as part of my collecting various linker fixes? -Kees -- Kees Cook 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=-9.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,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 E66F5C47083 for ; Wed, 2 Jun 2021 19:34:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B6FC1613F5 for ; Wed, 2 Jun 2021 19:34:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6FC1613F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DZRWQLUEvFJOLACi9g/B153uu2aoLfoQz1WT0fVYmb0=; b=REiU/xx3xfE+M+ 0h4FtavZckG5LT93eSKFCeLfXXn1LCvhLs22eBXFm1vS+ZndDvHopgmtpHKzYsD8WpYvxgjVVso/Y dIX3Ah8KxDWymt/b7Tntp1Xj3uGQhwWKGHYiHg/93vaMtf7T6DNMz+GkknCczb1KUaTG3NyTwoJLB YnTPvmVCudWBmeZQqCTnkWTCmwUaiZEud/eURwLcpHMG+5xUarP+FaCswUf/cX+hoUHpRBj6od2JX SiLmAITGw5llnQ0x9YZ64HeEp4xbR4N6bf+qdS+Mt5T1biAfyFbsWVFXvN9/F4EDLyc5vUeoxvlPM hVvzt+SNuRYCCojbTXZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loWbg-005yP2-MF; Wed, 02 Jun 2021 19:32:48 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loWbc-005yOC-Ey for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 19:32:46 +0000 Received: by mail-pl1-x633.google.com with SMTP id c13so1658106plz.0 for ; Wed, 02 Jun 2021 12:32:42 -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=4e1fH+i/4Nf38IYF0J8GBj+xdjCqFkdwdWN2L+YElMY=; b=Ne32eZA/sGKOBjJXF16uA1Y7T7rMhnXh2Ziva3sUZQP7FIVtan8BXlbrdVQNOmpa4p mo/McA3nj5bdJ8g+VPCr8ob3beUa2nLTODFoxdssvqecrarIo41wLITRf0AJXYuPjaQ1 ue/xanHzLqGBHkNJaokCOOu1NKQaUL25OIc0E= 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=4e1fH+i/4Nf38IYF0J8GBj+xdjCqFkdwdWN2L+YElMY=; b=RN0PyakHdV59l7Igq9Vf7MlWx0yZ46f9JWeJBkMOA/HD436qcfi5/x4smJLaWyOg+2 QFL/c2S715fDInlqLHCck+UwvSpp61AEF6uaknCDm71cFeb2Vc2jvFc9xpzHiQjoytfb Hn1ZDF/HnT3jny6HI+D9k14W9Xv4ZfrKIp+ZndCTWeElNInvlljNh+fcySvlIx/m3SkG KBS0nmDpvzXi8Rjv06SxkYlJOu5ZCthLGuY8dcWXgZ7o5IdObPJn1xE9F0AkrwwSKtbT YE6G3ti3BPAFR8PuoAVZx1qgJgGmq7Xc/9eV3KVeQygrtR0FxhSs91PVTgt/yl5pGB9N r6Pw== X-Gm-Message-State: AOAM533OSzIfALqbEL3jxqAdu0eHvzC6Tvg7Nn7UDBoKEAxJnim7NixJ LXz9TTZjpbE3JBntM5teH6ROBWrMj2eFDQ== X-Google-Smtp-Source: ABdhPJzjgGtjqvUgiVc2BReU2BmJawBbl2m8YPOEjnFEOGPI2Ik7hFRqbL7Rng0mBo3lXOCsMHkAfQ== X-Received: by 2002:a17:90a:f304:: with SMTP id ca4mr27502271pjb.177.1622662361679; Wed, 02 Jun 2021 12:32:41 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u23sm31828pgk.38.2021.06.02.12.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 12:32:41 -0700 (PDT) Date: Wed, 2 Jun 2021 12:32:40 -0700 From: Kees Cook To: Catalin Marinas Cc: Arnd Bergmann , Fangrui Song , Will Deacon , Ard Biesheuvel , Mark Rutland , Marc Zyngier , David Brazdil , Linux ARM , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section Message-ID: <202106021231.A1B7A10@keescook> References: <20210226140352.3477860-1-arnd@kernel.org> <202102261256.AF256702@keescook> <20210227043257.k3aernmnzsvitp7c@google.com> <20210316104530.GA7309@arm.com> <20210316162745.GA20565@arm.com> <20210316190921.GB28565@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210316190921.GB28565@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_123244_544885_0C960E64 X-CRM114-Status: GOOD ( 32.91 ) 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 Tue, Mar 16, 2021 at 07:09:23PM +0000, Catalin Marinas wrote: > On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote: > > On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas wrote: > > > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote: > > > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote: > > > > > On 2021-02-26, Kees Cook wrote: > > > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote: > > > > > > > From: Arnd Bergmann > > > > > > > > > > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, > > > > > > > I sometimes see an assertion > > > > > > > > > > > > > > ld.lld: error: Entry trampoline text too big > > > > > > > > > > > > Heh, "too big" seems a weird report for having it discarded. :) > > > > > > > > > > > > Any idea on this Fangrui? > > > > > > > > > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 ) > > > > > > > > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds > > > > > > > > > > ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16), > > > > > "Entry trampoline text too big") > > > > > > > > Can we not change the ASSERT to be <= PAGE_SIZE instead? > > > > > > Ah, that won't work as I suspect we still need the trampoline section. > > > > > > Arnd, do you know why this section disappears? I did a simple test with > > > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is > > > still around. > > > > If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE > > is disabled, which dropped the only reference into this section. > > If that doesn't make sense, I can try digging through the old build logs to > > reproduce the problem. > > I suspected this as well but still worked for me when disabling it. > > Anyway, I don't think identifying the exact option is necessary. With > CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only > __entry_tramp_text_start/end are referenced. > > In this case we happened to detect this issue because of the ASSERT in > vmlinux.lds.S but I wonder what else the linker drops with this dead > code elimination that we may not notice (it seems to remove about 500KB > from the resulting image in my test). > > I'll push these two patches to -next for wider coverage before deciding > on mainline (though the option may not get much testing as it's hidden > behind EXPERT and default n). I don't see this in -next? Catalin, do you want me to pick it up as part of my collecting various linker fixes? -Kees -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel