]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
netconsole: don't drop the last byte of a full-sized message
authorBreno Leitao <leitao@debian.org>
Tue, 16 Jun 2026 16:09:52 +0000 (09:09 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 19 Jun 2026 01:08:41 +0000 (18:08 -0700)
commitc0ebe492329a4d29592e2240df17e56724849f1f
treea6c12646fceb33ca90b3b73ab8157222971c5ab3
parentbf6e8af2c8be77489bedeae9f8a9654cb710e500
netconsole: don't drop the last byte of a full-sized message

nt->buf is exactly MAX_PRINT_CHUNK bytes, but scnprintf() reserves one
byte for its NUL terminator, so a non-fragmented payload of exactly
MAX_PRINT_CHUNK loses its last byte (emitted as a stray NUL in the
release path). Grow nt->buf to MAX_PRINT_CHUNK + 1 and bound the
scnprintf() calls with sizeof(nt->buf); the transmitted length stays
capped at MAX_PRINT_CHUNK.

Alternatively, nt->buf could be left at MAX_PRINT_CHUNK and the NUL byte
reserved by routing exactly-MAX_PRINT_CHUNK payloads to fragmentation
('len < MAX_PRINT_CHUNK'), at the cost of fragmenting those messages.
But it would look less sane, thus the current approach.

Fixes: c62c0a17f9b7 ("netconsole: Append kernel version to message")
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260616-max_print_chunk-v1-1-8dc125d67083@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netconsole.c