lkml.org 
[lkml]   [2019]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved
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 <bjorn.andersson@linaro.org>
> ---
> 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 <will.deacon@arm.com>

Catalin can pick this up as a fix for 5.1.

Will

\
 
 \ /
  Last update: 2019-04-23 11:56    [W:0.043 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site