Re: [RFC PATCH] initramfs: Add size validation to prevent tmpfs exhaustion
From: Stephen Eta Zhou
Date: Tue Mar 18 2025 - 08:38:34 EST
> 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@xxxxxxx>
Sent: Tuesday, March 18, 2025 17:51
To: Stephen Eta Zhou <stephen.eta.zhou@xxxxxxxxxxx>
Cc: jsperbeck@xxxxxxxxxx <jsperbeck@xxxxxxxxxx>; akpm@xxxxxxxxxxxxxxxxxxxx <akpm@xxxxxxxxxxxxxxxxxxxx>; gregkh@xxxxxxxxxxxxxxxxxxx <gregkh@xxxxxxxxxxxxxxxxxxx>; lukas@xxxxxxxxx <lukas@xxxxxxxxx>; wufan@xxxxxxxxxxxxxxxxxxx <wufan@xxxxxxxxxxxxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx <linux-kernel@xxxxxxxxxxxxxxx>; linux-fsdevel@xxxxxxxxxxxxxxx <linux-fsdevel@xxxxxxxxxxxxxxx>
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.