* [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved
@ 2019-04-18 4:29 ` Bjorn Andersson
0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Andersson @ 2019-04-18 4:29 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Florian Fainelli
Cc: linux-arm-kernel, linux-kernel, stable
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;
/*
* We can only add back the initrd memory if we don't end up
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved
@ 2019-04-18 4:29 ` Bjorn Andersson
0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Andersson @ 2019-04-18 4:29 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Florian Fainelli
Cc: stable, linux-kernel, linux-arm-kernel
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;
/*
* We can only add back the initrd memory if we don't end up
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved
2019-04-18 4:29 ` Bjorn Andersson
@ 2019-04-23 9:56 ` Will Deacon
-1 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2019-04-23 9:56 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Catalin Marinas, Florian Fainelli, linux-arm-kernel,
linux-kernel, stable
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved
@ 2019-04-23 9:56 ` Will Deacon
0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2019-04-23 9:56 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Catalin Marinas, stable, Florian Fainelli, linux-kernel,
linux-arm-kernel
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-23 9:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 4:29 [PATCH] arm64: mm: Ensure tail of unaligned initrd is reserved Bjorn Andersson
2019-04-18 4:29 ` Bjorn Andersson
2019-04-23 9:56 ` Will Deacon
2019-04-23 9:56 ` Will Deacon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.