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=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT 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 C6952C282DD for ; Tue, 23 Apr 2019 09:56:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94A0A21773 for ; Tue, 23 Apr 2019 09:56:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727234AbfDWJ4M (ORCPT ); Tue, 23 Apr 2019 05:56:12 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52996 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfDWJ4L (ORCPT ); Tue, 23 Apr 2019 05:56:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 49289374; Tue, 23 Apr 2019 02:56:11 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 162DA3F557; Tue, 23 Apr 2019 02:56:09 -0700 (PDT) Date: Tue, 23 Apr 2019 10:56:05 +0100 From: Will Deacon To: Bjorn Andersson Cc: Catalin Marinas , Florian Fainelli , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved Message-ID: <20190423095605.GA28879@fuggles.cambridge.arm.com> References: <20190418042929.20189-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190418042929.20189-1-bjorn.andersson@linaro.org> User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 17, 2019 at 09:29:29PM -0700, Bjorn Andersson wrote: > In the event that the start address of the initrd is not aligned, but > has an aligned size, the base + size will not cover the entire initrd > image and there is a chance that the kernel will corrupt the tail of the > image. > > By aligning the end of the initrd to a page boundary and then > subtracting the adjusted start address the memblock reservation will > cover all pages that contains the initrd. > > Fixes: c756c592e442 ("arm64: Utilize phys_initrd_start/phys_initrd_size") > Cc: stable@vger.kernel.org > Signed-off-by: Bjorn Andersson > --- > arch/arm64/mm/init.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 6bc135042f5e..7cae155e81a5 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -363,7 +363,7 @@ void __init arm64_memblock_init(void) > * Otherwise, this is a no-op > */ > u64 base = phys_initrd_start & PAGE_MASK; > - u64 size = PAGE_ALIGN(phys_initrd_size); > + u64 size = PAGE_ALIGN(phys_initrd_start + phys_initrd_size) - base; Acked-by: Will Deacon Catalin can pick this up as a fix for 5.1. Will 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=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT 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 AF100C10F14 for ; Tue, 23 Apr 2019 09:56:22 +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 7C91120843 for ; Tue, 23 Apr 2019 09:56:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G0sbwWuo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C91120843 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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.20170209; h=Sender: Content-Transfer-Encoding:Content-Type: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=E9HFbdEhb6av2cEK5GFjwFUDKMIpBJFEYlb906Bw0KM=; b=G0sbwWuoOfjyym QlGIgDEjtsu2mN6XZLVVjAfJyQhubJY58p7RiD81zAgIvZZ6xeeb+KuAMLdIjJatTbyHYK5GvOa6g 2t0Ad4uUrF34p19qCKLjN1Sjqph2PkWmVLcbgEyK1UeQyPDZaeOKUF1VcvWCJrnSEHjXTLKRLYgEZ ujsN/+/avUwg9L8IZN7jkQYxxuiAOpHaC7NIjtg+A0KovMXNQ+uT1F8QdTeTOe4NAEBY1hBp6nljJ Ly0h8YDIbTVr1tjDuO9Z9zV2yASbl5UdYWT+SgAtzhPEHgYcglggALe/A5+9wQCDiByD41MwatV1/ Uvq5XfKzw8P8oMpVOm3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIs9w-0004LX-7P; Tue, 23 Apr 2019 09:56:16 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIs9t-0004Kf-JK for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2019 09:56:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 49289374; Tue, 23 Apr 2019 02:56:11 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 162DA3F557; Tue, 23 Apr 2019 02:56:09 -0700 (PDT) Date: Tue, 23 Apr 2019 10:56:05 +0100 From: Will Deacon To: Bjorn Andersson Subject: Re: [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved Message-ID: <20190423095605.GA28879@fuggles.cambridge.arm.com> References: <20190418042929.20189-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190418042929.20189-1-bjorn.andersson@linaro.org> User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190423_025613_642635_6E5ED98B X-CRM114-Status: GOOD ( 17.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , stable@vger.kernel.org, Florian Fainelli , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 17, 2019 at 09:29:29PM -0700, Bjorn Andersson wrote: > In the event that the start address of the initrd is not aligned, but > has an aligned size, the base + size will not cover the entire initrd > image and there is a chance that the kernel will corrupt the tail of the > image. > > By aligning the end of the initrd to a page boundary and then > subtracting the adjusted start address the memblock reservation will > cover all pages that contains the initrd. > > Fixes: c756c592e442 ("arm64: Utilize phys_initrd_start/phys_initrd_size") > Cc: stable@vger.kernel.org > Signed-off-by: Bjorn Andersson > --- > arch/arm64/mm/init.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 6bc135042f5e..7cae155e81a5 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -363,7 +363,7 @@ void __init arm64_memblock_init(void) > * Otherwise, this is a no-op > */ > u64 base = phys_initrd_start & PAGE_MASK; > - u64 size = PAGE_ALIGN(phys_initrd_size); > + u64 size = PAGE_ALIGN(phys_initrd_start + phys_initrd_size) - base; Acked-by: Will Deacon Catalin can pick this up as a fix for 5.1. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel