Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4815524yba; Tue, 30 Apr 2019 04:59:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgo3vmt8vAPiLegQ7QYNzY9pR+ICFqo72dMdhM4zZVbBmJGGSRt5Xo3rBS0sysUYDdgnz3 X-Received: by 2002:a17:902:442:: with SMTP id 60mr70014593ple.107.1556625585430; Tue, 30 Apr 2019 04:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625585; cv=none; d=google.com; s=arc-20160816; b=wHmSnKn7iGmd29BeKpLi80JqRdPTUFKt1SWiDBCH40obZZF3ScgBv8BcJOo30fKVS8 6VgPr6LHYrr0SnjaCmayCm9hbi5bTaZ4d9IbU8c0l7JonPhztxDqGwR9MYB0nhglVvwn 35MvwgIuT8snUmDrSCASRZNKLI5lpLHEaVYqGd4D/zhu5bM8o8w9PJxCnKJuqtbBBRqR ApSz5wt39/5jSZpL67crruXWFED0B/Wi2OYVg0QILh9EvsstJJmNO26hHMCgZC7VMQHO 0ur0StIpZrK/w9L+QukavunQqhpbEJrHzMgjKFFskqY6zs/RnNPbyi6QAZKk7Ef1b0cs VAlw== 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 n5si9113954pgj.365.2019.04.30.04.59.29; Tue, 30 Apr 2019 04:59:45 -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 S1727180AbfD3L4m (ORCPT + 99 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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