Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp303228pxj; Thu, 20 May 2021 09:40:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRqpt6y+24LCa4WliegzHku7h8Uqw8hHhtVQLoSPT+dDXcDOcjidpUnl8rLLSIIjVBvQxz X-Received: by 2002:a17:906:c314:: with SMTP id s20mr2496887ejz.521.1621528814179; Thu, 20 May 2021 09:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621528814; cv=none; d=google.com; s=arc-20160816; b=mLy74+sxSF3alFsbwctl1Hw8NJZJjL4rOSOd/7+DrsC0B70qDqnTkQexbidtgN8RHY jfWbAU9z/a6Z1JwRV1wySuriYsIhwb0fG8SrcPrXnMLIbWGZqrUESiXbxwvoXK8Nv0w7 zIGxb5nfwqEGJvTSg3i1syJhPp7fQzJ7YeLQiJ5MVsXU/Ab+l+ZlaSbsdFGl52W546Qj QSM6YfKu7HJtfIbFvBWeifdGO9005UQAfEfHoIIhrQ4xOm7TL3RU4l0EO46vOQVqwjr3 VQb4By6iva1LcfCIVAwyUuIJpow96PgIz3Kn4OtHifEATykTWH1K/lup5n1hID8kfHb6 D0vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wpo1NJIhTQoHeW2cWQRvsbUMHD9cWnVqiT2PF5pDpGg=; b=vcefU30IRgKJzqSMdmjcWyVcxzV5xVUwJRpb7/7k5RRMYcdqFQgR6BEBxG+wxFAIv6 Q8mYp3yWOsBNLfKtq/JH+dnigYWk8tCHL+cf2u7P93/cvr7YDdYAMsOcwtsBj/qAP3AV E+2Rk+RLmu55V5yZgbCDl78cEj/EOyXTHwEcDqwL4VzNNam3WmWVmktj+B+MXM+3vkNu mOwUQzP7vsBajhul8RlzI6CJrx7vp3uLk5prxc79c4+A1C9TJHe7vEN2fL2zmwrtd7VO YZxQGx7g5Dzu0GZL1G8sz0awccu/ks0l8z2CjdWOiwgmA1IeFgkYl2pUMgwpthEbAqgF XMgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FQsB0EaC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si2896181ejp.350.2021.05.20.09.39.43; Thu, 20 May 2021 09:40:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FQsB0EaC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233330AbhETJlM (ORCPT + 99 others); Thu, 20 May 2021 05:41:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:39950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232543AbhETJhl (ORCPT ); Thu, 20 May 2021 05:37:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B3896141D; Thu, 20 May 2021 09:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503024; bh=zbaVimS/me7y1CfvU8+PbrDl8XBI5eoCniEAMjtcI68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FQsB0EaCdbGzTTmcpzG58++RVGaxba3IkKpUIxMl0Ryfra19ctPs+vRfk+qRSvkth huIReaz7NvbGnng7nbtoqir2doegejZx8jsasOSFE8fa5EppI07sPE4f6TNsmC/uBp HBiIoMyl/39bwI5zrPZpGh0Z5R5L80jZl+sueQy0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Desaulniers , Guillaume Tucker , "kernelci.org bot" , Ard Biesheuvel , Russell King Subject: [PATCH 4.19 005/425] ARM: 9056/1: decompressor: fix BSS size calculation for LLVM ld.lld Date: Thu, 20 May 2021 11:16:14 +0200 Message-Id: <20210520092131.506187178@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit c4e792d1acce31c2eb7b9193ab06ab94de05bf42 upstream. The LLVM ld.lld linker uses a different symbol type for __bss_start, resulting in the calculation of KBSS_SZ to be thrown off. Up until now, this has gone unnoticed as it only affects the appended DTB case, but pending changes for ARM in the way the decompressed kernel is cleaned from the caches has uncovered this problem. On a ld.lld build: $ nm vmlinux |grep bss_ c1c22034 D __bss_start c1c86e98 B __bss_stop resulting in $ readelf -s arch/arm/boot/compressed/vmlinux | grep bss_size 433: c1c86e98 0 NOTYPE GLOBAL DEFAULT ABS _kernel_bss_size which is obviously incorrect, and may cause the cache clean to access unmapped memory, or cause the size calculation to wrap, resulting in no cache clean to be performed at all. Fix this by updating the sed regex to take D type symbols into account. Link: https://lore.kernel.org/linux-arm-kernel/6c65bcef-d4e7-25fa-43cf-2c435bb61bb9@collabora.com/ Link: https://lore.kernel.org/linux-arm-kernel/20210205085220.31232-1-ardb@kernel.org/ Cc: # v4.19+ Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Reported-by: Guillaume Tucker Reported-by: "kernelci.org bot" Signed-off-by: Ard Biesheuvel Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- arch/arm/boot/compressed/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -121,8 +121,8 @@ asflags-y := -DZIMAGE # Supply kernel BSS size to the decompressor via a linker symbol. KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \ - sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \ - -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) ) + sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \ + -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) ) LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) # Supply ZRELADDR to the decompressor via a linker symbol. ifneq ($(CONFIG_AUTO_ZRELADDR),y)