From patchwork Thu Apr 18 04:29:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 162435 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp272794jan; Wed, 17 Apr 2019 21:29:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+qPPz4W652i3aKOAbnnw3mZOREZUB75FEZureuaIrYI6tfa07+xYg5b+2cp6q8Vwd566V X-Received: by 2002:a17:902:7441:: with SMTP id e1mr90989230plt.13.1555561778789; Wed, 17 Apr 2019 21:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555561778; cv=none; d=google.com; s=arc-20160816; b=Fc591N3Q/qzQbWGyhIgP2BzzZLUF1jML1HdzdCXntkJM+iUThRla/Z1SiOM/OroIJZ 994MZ5hpd7L0mDwWU/+AAkWlI1bdY2JKQ1M4huUzzb2iAdaDR5POKVZh69z6vO++n2qr j3ZJ57ghKKn7B6gSYeh96GsnE2/6hvLSjqgMw0FCUGhU9U9ft7ZqiiaAVL08Bvnx87JG uFKwte9mbFSeVr0ghGWDCZOAxDfw3AX6WxNvcIUOo6KmyeSlHQRGUe24izZvCKo5ayzn uxfVO3mjkpwfF1x7iIrf81BVFd9CtTXu0bQtaiPoMygE4W38IzoDN6ui76j7eUAPAaH/ y13Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=TKvJUjK7viyJQFwyOe6XFkoQSCknOeuCFER0aL1PpnE=; b=onoPJs4po3mBhpHUZltDyfAtVH/BOKNvRDJ6jS9xHcNmnxOILJc/cdET0Wz4y/4rxH zAlEZ1vnyLaLA4SDzj7MuOLn9OcuFUSwQ7RG4UrjRPCKSZsxK4EOyZ36TJq2nA8QLD9Q XU1hzsEe7XAmzvqOsOX+mlLy7dgK916yU2enh01mRAau1IHU9hV/hekTTobsg8tl7m8E nQRkZXuOoU9blMPLhBQl3SXCSFwfSura3D/Pp8wyernWMeYlAyRqlKCtLQXmSzyzcmi0 o+d8vjDlKoW0Ga9CHcU8Vk7HV/gBuR39o80YPby76SLDdz8W5tqMKkPNrL8KCtqJjZoW IwrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LN97jJeh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si1030179pls.46.2019.04.17.21.29.38; Wed, 17 Apr 2019 21:29:38 -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=@linaro.org header.s=google header.b=LN97jJeh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbfDRE3e (ORCPT + 30 others); Thu, 18 Apr 2019 00:29:34 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37784 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbfDRE3d (ORCPT ); Thu, 18 Apr 2019 00:29:33 -0400 Received: by mail-pg1-f193.google.com with SMTP id e6so574116pgc.4 for ; Wed, 17 Apr 2019 21:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=TKvJUjK7viyJQFwyOe6XFkoQSCknOeuCFER0aL1PpnE=; b=LN97jJehjH6C+AEZXWqpJM/QmCuaEeYRfVcKRKtIX0XHD9/txxYDIJIEQsJnNY2air oW+d/jhPbFMHyys7m7G99Ntcwp48/kwzYNYScNkMBVyDlR9TnzSwn5XaqgoK8EXR04bH Mgl7+n7TdO+8NEPlY3WDSsgAZbNPgPfFXIVwejkXFf+nm8uyfcSC+XIFvhjMo91Cut8M 9gSGtYyz2M9E9LnA/3Bz64Wb18Yp6pThW5q9SsqhGyU1akORmC73MfTyXfvIqzUGMuFy Rod2az/Byy9Kkru5rpPg1+mdGtz5af542PshLgnEGUeFZs26KPcVChjI11DxWr6ANyP2 OzYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TKvJUjK7viyJQFwyOe6XFkoQSCknOeuCFER0aL1PpnE=; b=YiTwt47g4lSNhC3MpJS8MBh58r84/pvBrVjdX/M5a/8zLS46+TjxAprV4XNObJvyqV eWZMpy2ocf3QK0+WLLkuUZuDxj2I1NWReEQ3AnTQpLQLFQ5AXt/6C1tS8WqRIL/Hmiea xx5b9mnM2hfFWHS/yOsjeAA72CUm0jCCsEtJJjZPFG7r+0pqh5snT+rLGUMZ+R2JsWZg 0v5zzDWeZsm8VPHBZHXdEmYTgKIBJiFVM9XH0gouhTD1Co7Fp0Kx7xevHBrz7m0X9jxN JzxE9QqwESk0htUYi0LZdPoD3RvTS8baNBi6hfaCtkYwnYI4T1vtnsnMFnTdpoS8QL4q QGFA== X-Gm-Message-State: APjAAAVBzQRhzf2Jp7CCbqz3FZeZm/lBjyPUNWaU7q4dkQi40aMH5Y/s hFA0YG44dFgUzyoXqHBy/j2tNQ== X-Received: by 2002:a62:1881:: with SMTP id 123mr93460803pfy.25.1555561772724; Wed, 17 Apr 2019 21:29:32 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r24sm1003922pfd.120.2019.04.17.21.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 21:29:31 -0700 (PDT) From: Bjorn Andersson To: Catalin Marinas , Will Deacon , Florian Fainelli Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved Date: Wed, 17 Apr 2019 21:29:29 -0700 Message-Id: <20190418042929.20189-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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; /* * We can only add back the initrd memory if we don't end up