Re: [RFC PATCH] initramfs: Add size validation to prevent tmpfs exhaustion

Stephen Eta Zhou
2025-03-18T12:37:02Z

> Not always. The *built-in* initramfs unpack_to_rootfs() error path
> panics, but external initramfs unpack_to_rootfs() failure won't panic
> immediately...

You're right that the behavior differs between built-in and external initramfs handling. My concern is primarily about the built-in case, where unpack_to_rootfs() will lead to a panic if decompression fails.

> Are your console/serial drivers loaded as external modules? That sounds
> like a configuration problem.

My console and serial port drivers are built into the kernel. I found that if the built-in initramfs fails to be decompressed, it will enter a suspended state when panic is called, and no logs will be output (my test environment at this time does not have the early serial port). After debugging, I found that console_flush_all did not seem to find an available console. I will debug this problem in depth next.

Thanks,
Stephen
________________________________________
From: David Disseldorp <ddiss@suse.de>
Sent: Tuesday, March 18, 2025 17:51
To: Stephen Eta Zhou <stephen.eta.zhou@outlook.com>
Cc: jsperbeck@google.com <jsperbeck@google.com>; akpm@linux-foundation.org <akpm@linux-foundation.org>; gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>; lukas@wunner.de <lukas@wunner.de>; wufan@linux.microsoft.com <wufan@linux.microsoft.com>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; linux-fsdevel@vger.kernel.org <linux-fsdevel@vger.kernel.org>
Subject: Re: [RFC PATCH] initramfs: Add size validation to prevent tmpfs exhaustion

On Tue, 18 Mar 2025 06:28:53 +0000, Stephen Eta Zhou wrote:

> > There's room for improvement WRT how out-of-memory failures are reported
>
> I am currently trying to find a good optimization solution for this. Since initramfs is decompressed in the early stage of the kernel, if the decompression fails, it will call panic to put the kernel into a panic state.

Not always. The *built-in* initramfs unpack_to_rootfs() error path
panics, but external initramfs unpack_to_rootfs() failure won't panic
immediately...

> There is a contradiction: at this time, the console and serial port have not been initialized yet, which will cause the error message to fail to be output, resulting in a suspended state, and no valid output can be seen.

Are your console/serial drivers loaded as external modules? That sounds
like a configuration problem.