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=-18.8 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,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS 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 E4D2BC433E0 for ; Sat, 27 Feb 2021 04:34:32 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9C61E64E4D for ; Sat, 27 Feb 2021 04:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C61E64E4D 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=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=M86ulBNEhgJtuLm+7Lci2lEO7czQM3YOpWWa5RBkPOA=; b=OmLw2wl25qHQXNA0Q1NYkouQk LUF8bh2KL0CFs29IxVrEhVYeWfrThad4By5eB0uQhj/pMNd57hba0EBiZcbRXlzFOJCQKJEuHSoDa Rd/IzTaN7iPHeh+HkaAhkYibZLDeCtWDafWrPABpUFmzQgZimahZgfG6NnKP2Dm+luaxYfZtCDb1z 1fIS469zQnk9DM9jb2C5yGUiuPePkTO4zSHFg97Mzhizo106L/syq5dYTyLSK9IE2g55H0+EbK1uC xlq8MXj7X0dNsHoDZbmc6O/UMDj2P/UWXIqYnxIr4M66C0Yk/33NiqW9119FgF31sUzTMSjiZOtyd P7pPGImPw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFrHx-0003QR-Kl; Sat, 27 Feb 2021 04:33:09 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFrHu-0003Pn-J5 for linux-arm-kernel@lists.infradead.org; Sat, 27 Feb 2021 04:33:07 +0000 Received: by mail-pf1-x431.google.com with SMTP id l7so3400295pfd.3 for ; Fri, 26 Feb 2021 20:33:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=acGrNbfX1ONJlBYzGoeWien8tX1BAEMbXbxus24dvo4=; b=VwhYGS10gHHtx4bHrQ+wdwiMVGIFYdndXhNbDSfz8LMNKUZDsxDS77KcBXcM48iDsf 9Yx4pIOReijOyL27CHIKdm8BwvkfjeEYo9cDnsBzlVmT7Ox1+zJUDuXeWPtcn1d8D7dS NjIRO1lR9xVX6PnAd2pqMx6+nfu0y2yeWfL9J6XBE50qTOjiwP8sppW9V8NxCvMW/Pmi hXh3f/58KJZhyZKf7TTCoQP9cDYdD0AGueo9F6F1MhCKkTcjlvmOVTVoXGLxP+W+uXaF I6kOux4osK/cQG/fBojEJSHumtDiGPajb8aGeeBidUi7StBiFkkxhioNoOmFhDcAHY/O ImIA== 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=acGrNbfX1ONJlBYzGoeWien8tX1BAEMbXbxus24dvo4=; b=XjjhGa03IoUyease9VHWj7/qWK772Mnjc/o3zSygwR6Md9Cm95BlPOWA1Lap+dfpex hA6T+KHXhlPgiFZQDHfI53usIO+hxOF6cbJDY74XcS3ut+AU/NMtMSSv1h7o9mXPb3m+ jREEy8mBlCp4TjPUEHS6/VxhJcGdZX8B4t/A8vdmBPYmyWNs6T7ajPhFVD4o1GnfDQ6R KBG/r8en56eUUbf+pKlYfNIek42VKRAyrzBcNcshBjyDqD4xuv8Mx7A83NoJm7H+8Eu/ AnkhHsuuedfRUu92G+5xGGjEhu1i3qhZwXP/VU1JeBY7N4fEsW7xPA34dCiVqdrd6s3F fAfA== X-Gm-Message-State: AOAM533akE61dQGRcdtczBw267g9fNA16DzcTjOsTt63GnY4zXPo1O+u 3rD28+67EnrbX+lWNxOtPi6LGQ== X-Google-Smtp-Source: ABdhPJz7f04Lrx3tfHHrsCRXLLVkuuTouZTHKhhx2qi6IMSYDexUKG5EZ6UhtonHmgDkT+l9SID3fg== X-Received: by 2002:a63:a22:: with SMTP id 34mr5663613pgk.328.1614400380990; Fri, 26 Feb 2021 20:33:00 -0800 (PST) Received: from google.com ([2620:15c:2ce:0:48ad:d4d0:f627:c01f]) by smtp.gmail.com with ESMTPSA id v5sm10761519pfc.100.2021.02.26.20.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Feb 2021 20:33:00 -0800 (PST) Date: Fri, 26 Feb 2021 20:32:57 -0800 From: Fangrui Song To: Kees Cook Subject: Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section Message-ID: <20210227043257.k3aernmnzsvitp7c@google.com> References: <20210226140352.3477860-1-arnd@kernel.org> <202102261256.AF256702@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202102261256.AF256702@keescook> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210226_233306_673925_59569462 X-CRM114-Status: GOOD ( 22.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Arnd Bergmann , Arnd Bergmann , Catalin Marinas , linux-kernel@vger.kernel.org, Marc Zyngier , David Brazdil , Will Deacon , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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") In our case (aarch64-linux-gnu-ld or LLD, --gc-sections), all the input sections with this name are discarded, so the output section is either absent (GNU ld) or empty (LLD). KEEP makes the sections GC roots, and it is appropriate to use here. However, I worry that many other KEEP keywords in vmlinux.lds are unnecessary: https://lore.kernel.org/linux-arm-kernel/20210226211323.arkvjnr4hifxapqu@google.com/ git log -S KEEP -- include/asm-generic/vmlinux.lds.h => there is quite a bit unjustified usage. Sure, adding KEEP (GC root) is easy and works around problems, but it not good for CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. Reviewed-by: Fangrui Song > >> >> This happens when any reference to the trampoline is discarded at link >> time. Marking the section as KEEP() avoids the assertion, but I have >> not figured out whether this is the correct solution for the underlying >> problem. >> >> Signed-off-by: Arnd Bergmann > >As a work-around, it seems fine to me. > >Reviewed-by: Kees Cook > >-Kees > >> --- >> arch/arm64/kernel/vmlinux.lds.S | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S >> index 926cdb597a45..c5ee9d5842db 100644 >> --- a/arch/arm64/kernel/vmlinux.lds.S >> +++ b/arch/arm64/kernel/vmlinux.lds.S >> @@ -96,7 +96,7 @@ jiffies = jiffies_64; >> #define TRAMP_TEXT \ >> . = ALIGN(PAGE_SIZE); \ >> __entry_tramp_text_start = .; \ >> - *(.entry.tramp.text) \ >> + KEEP(*(.entry.tramp.text)) \ >> . = ALIGN(PAGE_SIZE); \ >> __entry_tramp_text_end = .; >> #else >> -- >> 2.29.2 >> > >-- >Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel