From patchwork Tue Apr 30 11:38:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 163108 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp3125061ill; Tue, 30 Apr 2019 04:56:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqytIMZ17olFibv8ZPwEKmFErDjll6QFUl3LoXH+jTfjUVyntY62q5fEDhdLOhQM2d3e6Fd4 X-Received: by 2002:a63:d709:: with SMTP id d9mr23879417pgg.38.1556625404235; Tue, 30 Apr 2019 04:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625404; cv=none; d=google.com; s=arc-20160816; b=MldKzIlmeIxqlie8N9DyNQU1txOB9Skd0NTVGtLo4HapEc+gaykGM2OFl6xabqPOaF 5FD7H/2qXAfDUgLsKqNIUc7lpQk9E9VIFSaDhxvX3Irj4k1gHX1LUUHm1jJCLSPcTfHp 6X/NMmPuB2GPGGBkrawb6Lv95m5Lv5mTlCU6UKGddNypb+XEfUngSePIhnV+nrSgq2zV 1EkU4+4sueVsa5PoHPzShpdHpNlY6hiBSqClklokB2C8uSVtHv19zW4hf69xvsEwdXM6 9gSHeOIcGxUzYYGHnVtzLNaxNjjwQIG2DtTKCZE2gfpw/j1+yYLgF+qTraHIhbJnSlmd mWOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8ymL4F1REAmxCrveF1TsJGM/pieulMMUoOWbdJpTs3k=; b=KrGwjm7Z1700zpa6TAPWlXEDGtnkXxkkxUb9xJOTrYq7FX9gLjK6JP3eFlMrA6O22V 4H6E3qcNGdeNOUa6SMY4+PVBDthJK6s79aPx5zAFECy4ANIb2pCuO6XnMVWZTVCJHWQn 1D6TfG5SSDJKFjGPcIo4fe/JeOuVyuDw+81GKwKCcgFGXmgc8RF7d3aabHdWwfeR4IE+ BgG54/EwOK7CCDJ55lv2CjHPIEnLUxCZFTRoIj9cX9pFZaSZYwiYBZbPSqHSY/hlK1PJ qAgmat+YOMr3c2fDc/FaBwMwZkoVL8hG6PohJ2X6UyXlMaAPkv9/xTJwrScjY7lTEpZV c8PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aG2XUpM6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si38105443plb.148.2019.04.30.04.56.43; Tue, 30 Apr 2019 04:56:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aG2XUpM6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727215AbfD3L4m (ORCPT + 30 others); Tue, 30 Apr 2019 07:56:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:34788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730875AbfD3Lsg (ORCPT ); Tue, 30 Apr 2019 07:48:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FFC520449; Tue, 30 Apr 2019 11:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556624915; bh=ZjSnPPE3GJxDV7BkqDZlz1xwMuO9b69kcF0NnUB0768=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aG2XUpM6BO/3Txynx4zXmYTbE0uvEiEDlXpaThnyxPiZ5IL3NIFd8IGyJWF7sCD9v KXQSUSM5Oyfh0Vaj/htIwsDvUcH7tsL3B9wW8hVmzP/vzrITlgTUa23kRKzHT9Fz+T fOZohROoE3KYCy3SmTjlxM1Xm6d5npzyzjyrYcn4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Bjorn Andersson , Catalin Marinas Subject: [PATCH 5.0 21/89] arm64: mm: Ensure tail of unaligned initrd is reserved Date: Tue, 30 Apr 2019 13:38:12 +0200 Message-Id: <20190430113611.059391513@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Andersson commit d4d18e3ec6091843f607e8929a56723e28f393a6 upstream. 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 Acked-by: Will Deacon Signed-off-by: Bjorn Andersson Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -406,7 +406,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; /* * We can only add back the initrd memory if we don't end up