[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e70ead93-2fe9-faf9-9e77-9df15809bad6@arm.com>
Date: Thu, 16 May 2019 15:05:31 +0100
From: Steven Price <steven.price@....com>
To: Mark Rutland <mark.rutland@....com>, Christoph Hellwig <hch@....de>
Cc: linux-kernel@...r.kernel.org, Mike Rapoport <rppt@...ux.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Will Deacon <will.deacon@....com>,
Catalin Marinas <catalin.marinas@....com>
Subject: Re: Bad virt_to_phys since commit 54c7a8916a887f35
On 16/05/2019 14:41, Mark Rutland wrote:
> On Thu, May 16, 2019 at 02:38:20PM +0100, Mark Rutland wrote:
>> Hi,
>>
>> Since commit:
>>
>> 54c7a8916a887f35 ("initramfs: free initrd memory if opening /initrd.image fails")
>
> Ugh, I dropped a paragarph here.
>
> Since that commit, I'm seeing a boot-time splat on arm64 when using
> CONFIG_DEBUG_VIRTUAL. I'm running an arm64 syzkaller instance, and this
> kills the VM, preventing further testing, which is unfortunate.
>
> Mark.
>
>> IIUC prior to that commit, we'd only attempt to free an intird if we had
>> one, whereas now we do so unconditionally. AFAICT, in this case
>> initrd_start has not been initialized (I'm not using an initrd or
>> initramfs on my system), so we end up trying virt_to_phys() on a bogus
>> VA in free_initrd_mem().
>>
>> Any ideas on the right way to fix this?
Your analysis looks right to me. In my review I'd managed to spot the
change in behaviour when CONFIG_INITRAMFS_FORCE is set (the initrd is
freed), but I'd overlooked what happens if initrd_start == 0 (the
non-existent initrd is attempted to be freed).
I suspect the following is sufficient to fix the problem:
----8<-----
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;
Powered by blists - more mailing lists