Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2701600pxj; Mon, 10 May 2021 08:51:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe0tUFhE43+HOhTHtd6HesogPah8eMIROzy6fgd086I3Io00wzyhBj9tGA/D2uGHPxkOTs X-Received: by 2002:a17:907:6289:: with SMTP id nd9mr25733819ejc.384.1620661890640; Mon, 10 May 2021 08:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620661890; cv=none; d=google.com; s=arc-20160816; b=cgShgsBzNPpP+GFTJJizuJd+oBmxn1n10c8Ollg/THA42D4qQiVTt5LYGKJ8grEErd nak41PKnVs83bSC5aQHbLPtnJ7xaaS+wJsfVsBxowGuedPQjgstTfVEm4Efdo1EUBuF2 atZr66F92khgvMpIjbZbgLCYMqEhC/xkrk7bJfx2RmAOxnz657ZqqwAF6f1EsTFkcxSz aXCy6oTEUts8DPM3NNG4LPDz97wMdIk10V6YjGibMd9wRagm9qS87ZCxmpYJgWbbviAO Sc4+KzWxIKsJLYdZ/o+adG1L+V89M2RlZsI0v4XX251hoosDByyKL4GsHK74F6ZBYKDx 9aBA== 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=zEhy0AsErk374tZ4h7fJ6YPW3QnOxAF5KFVvw+DJflM=; b=ojmJavsd6eFEX4XoE+wAbuXcMyWPi4tFETBDvwHHtgDusyepo1g39cbk2uvgMdVzSy /cCdAsA8/XhV5rQCnE3Wf25h3ThJtWgpVRM1fyEdgypg3bi5pKogfvhtL7q2TKVZaL9R rsWAD1BRGAen4ry4YW9AWHlCVSYM7iFfwr13UT88kgm/gcDtPlDGHIzA9+AZbcfu1WNd /uiOm2+k6XquN/rlwAP+/+wWWPC4WPRVVz0QMYHrkaeNithx4TfJigCUkj5jRff1o6xl 6pMa3A0bllnU94z52n7cXeue4bwRLQWnvP/+215SrhGoKKLQAxoZ9Ox8/armKKrQqMv9 +JJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u6MGkGCN; 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 y9si4208272edd.548.2021.05.10.08.51.06; Mon, 10 May 2021 08:51:30 -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=u6MGkGCN; 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 S239398AbhEJL0i (ORCPT + 99 others); Mon, 10 May 2021 07:26:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:52754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234416AbhEJK4V (ORCPT ); Mon, 10 May 2021 06:56:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 625106191D; Mon, 10 May 2021 10:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643555; bh=Mhh4GeQeXRy+ZKsM1D3kIggf4xYNEcIp85+akjZw8MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u6MGkGCN8MUHygJUj32mLDGMvdBmBDBAxgvXpfx20NzLJ3uN9H20xKC8Z9x8/6aCo QOSFLNyiYlXwZE+dwwVX5sxRu/zeuOoBiJA1hSNQlKf/D4gwr/7lged1bIlViswuPB nUxaAfiQ9sEAP3YdUKwbEo2qihni0SK5fPSxKypM= 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 5.11 017/342] ARM: 9056/1: decompressor: fix BSS size calculation for LLVM ld.lld Date: Mon, 10 May 2021 12:16:47 +0200 Message-Id: <20210510102010.673878174@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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 @@ -115,8 +115,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)