* [PATCH] initramfs: Don't free a non-existent initrd
@ 2019-05-16 14:31 Steven Price
2019-05-16 15:11 ` Mike Rapoport
0 siblings, 1 reply; 2+ messages in thread
From: Steven Price @ 2019-05-16 14:31 UTC (permalink / raw)
To: Andrew Morton, Mike Rapoport
Cc: Christoph Hellwig, linux-kernel, Steven Price, Mark Rutland
Since 54c7a8916a88 ("initramfs: free initrd memory if opening
/initrd.image fails"), the kernel has unconditionally attempted to free
the initrd even if it doesn't exist. In the non-existent case this
causes a boot-time splat if CONFIG_DEBUG_VIRTUAL is enabled due to a
call to virt_to_phys() with a NULL address.
Instead we should check that the initrd actually exists and only attempt
to free it if it does.
Fixes: 54c7a8916a88 ("initramfs: free initrd memory if opening /initrd.image fails")
Reported-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
---
init/initramfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/init/initramfs.c b/init/initramfs.c
index 435a428c2af1..178130fd61c2 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -669,7 +669,7 @@ static int __init populate_rootfs(void)
* If the initrd region is overlapped with crashkernel reserved region,
* free only memory that is not part of crashkernel region.
*/
- if (!do_retain_initrd && !kexec_free_initrd())
+ if (!do_retain_initrd && initrd_start && !kexec_free_initrd())
free_initrd_mem(initrd_start, initrd_end);
initrd_start = 0;
initrd_end = 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] initramfs: Don't free a non-existent initrd
2019-05-16 14:31 [PATCH] initramfs: Don't free a non-existent initrd Steven Price
@ 2019-05-16 15:11 ` Mike Rapoport
0 siblings, 0 replies; 2+ messages in thread
From: Mike Rapoport @ 2019-05-16 15:11 UTC (permalink / raw)
To: Steven Price; +Cc: Andrew Morton, Christoph Hellwig, linux-kernel, Mark Rutland
On Thu, May 16, 2019 at 03:31:25PM +0100, Steven Price wrote:
> Since 54c7a8916a88 ("initramfs: free initrd memory if opening
> /initrd.image fails"), the kernel has unconditionally attempted to free
> the initrd even if it doesn't exist. In the non-existent case this
> causes a boot-time splat if CONFIG_DEBUG_VIRTUAL is enabled due to a
> call to virt_to_phys() with a NULL address.
>
> Instead we should check that the initrd actually exists and only attempt
> to free it if it does.
>
> Fixes: 54c7a8916a88 ("initramfs: free initrd memory if opening /initrd.image fails")
> Reported-by: Mark Rutland <mark.rutland@arm.com>
> Tested-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
> init/initramfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/init/initramfs.c b/init/initramfs.c
> index 435a428c2af1..178130fd61c2 100644
> --- a/init/initramfs.c
> +++ b/init/initramfs.c
> @@ -669,7 +669,7 @@ static int __init populate_rootfs(void)
> * If the initrd region is overlapped with crashkernel reserved region,
> * free only memory that is not part of crashkernel region.
> */
> - if (!do_retain_initrd && !kexec_free_initrd())
> + if (!do_retain_initrd && initrd_start && !kexec_free_initrd())
> free_initrd_mem(initrd_start, initrd_end);
> initrd_start = 0;
> initrd_end = 0;
> --
> 2.20.1
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-16 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16 14:31 [PATCH] initramfs: Don't free a non-existent initrd Steven Price
2019-05-16 15:11 ` Mike Rapoport
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.