[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251021160657.29b745a94ff8cfd2fe92c7af@linux-foundation.org>
Date: Tue, 21 Oct 2025 16:06:57 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Doug Anderson <dianders@...omium.org>
Cc: linux-kernel@...r.kernel.org, Andrew Chant <achant@...gle.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Brian Gerst
<brgerst@...il.com>, Christian Brauner <brauner@...nel.org>, Francesco
Valla <francesco@...la.it>, Geert Uytterhoeven <geert+renesas@...der.be>,
Guo Weikang <guoweikang.kernel@...il.com>, Huacai Chen
<chenhuacai@...nel.org>, Jan Hendrik Farr <kernel@...rr.cc>, Jeff Xu
<jeffxu@...omium.org>, Kees Cook <kees@...nel.org>, Masahiro Yamada
<masahiroy@...nel.org>, Michal Koutný
<mkoutny@...e.com>, Miguel Ojeda <ojeda@...nel.org>,
"Mike Rapoport (Microsoft)" <rppt@...nel.org>, Nathan Chancellor
<nathan@...nel.org>, Peter Zijlstra <peterz@...radead.org>, Randy Dunlap
<rdunlap@...radead.org>, Shakeel Butt <shakeel.butt@...ux.dev>, Tejun Heo
<tj@...nel.org>, Thomas Gleixner <tglx@...utronix.de>, Thomas
Weißschuh <thomas.weissschuh@...utronix.de>,
"Uladzislau Rezki (Sony)" <urezki@...il.com>
Subject: Re: [PATCH] init/main.c: Wrap long kernel cmdline when printing to
logs
On Tue, 21 Oct 2025 15:57:18 -0700 Doug Anderson <dianders@...omium.org> wrote:
> In other words `dmesg` seemed to be trying to read 2047 bytes from
> `/dev/kmsg` and this wasn't enough to hold the output line. You can
> see in the kernel function devkmsg_read() that when this happens the
> kernel returns -EINVAL.
>
> We could _try_ to improve devkmsg_read() to be able to return partial
> log lines, but that violates the docs. The file
> `Documentation/ABI/testing/dev-kmsg` says:
>
> Every read() from the opened device node receives one record
> of the kernel's printk buffer.
> ...
> Messages in the record ring buffer get overwritten as whole,
> there are never partial messages received by read().
Well that was dumb of us. POSIX be damned.
> So tl;dr: as far as I can tell, we simply cannot put the whole cmdline
> (which is 2048+ on many architectures) on one line without breaking
> userspace. My userspace reads 2047 bytes and we'd need to return not
> just the cmdline but the prefix "Kernel command line:" as well as the
> data about time/log_level/etc.
>
>
> Does any of the above change your mind about my wrapping scheme? ;-)
Yeah.
> Obviously, I'd want to update my commit message with some of the
> research...
Sure.
Powered by blists - more mailing lists