Re: [PATCH v2] init/main.c: Wrap long kernel cmdline when printing to logs
From: Heiko Carstens
Date: Wed Oct 22 2025 - 05:30:39 EST
On Wed, Oct 22, 2025 at 11:16:06AM +0200, Geert Uytterhoeven wrote:
> Hi Douglas,
>
> On Wed, 22 Oct 2025 at 02:41, Douglas Anderson <dianders@xxxxxxxxxxxx> wrote:
> > The kernel cmdline length is allowed to be longer than what printk can
> > handle. When this happens the cmdline that's printed to the kernel
> > ring buffer at bootup is cutoff and some kernel cmdline options are
> > "hidden" from the logs. This undercuts the usefulness of the log
> > message.
> >
> > Specifically, grepping for COMMAND_LINE_SIZE shows that 2048 is common
> > and some architectures even define it as 4096. s390 allows a
> > CONFIG-based maximum up to 1MB (though it's not expected that anyone
> > will go over the default max of 4096 [1]).
>
> Of course (unless the kernel crashes) you can also look at /proc/cmdline
> later. However, that seems to be limited to a single page, too,
> as fs/proc/cmdline.c:cmdline_proc_show() uses seq_puts*().
proc seq_files are not PAGE_SIZE limited. If the output doesn't fit
into a single page the size of the buffer is doubled, until the output
fits into the buffer. See the while(1) loop in seq_read_iter().