]> git.hungrycats.org Git - linux/commit
scripts: modpost: detect and report truncated buf_printf() output
authorAlexandre Courbot <acourbot@nvidia.com>
Wed, 27 May 2026 11:52:17 +0000 (20:52 +0900)
committerNathan Chancellor <nathan@kernel.org>
Thu, 28 May 2026 16:57:13 +0000 (09:57 -0700)
commitd7231d8cb262b1e350c00271bf53d54414b4f3b1
treed57fc42056ee6365862f0dcbcbbded1445da4c22
parent159921d63da16ff1d4764e73ddf9e1556b54dfc8
scripts: modpost: detect and report truncated buf_printf() output

buf_printf() uses a fixed-size stack buffer. vsnprintf() returns the
number of bytes that *would* have been written to that buffer, which can
be larger than the size of said buffer if the formatted string is too
long.

The problem is that whenever this happens buf_printf() currently passes
this length, unchecked, to buf_write(), which silently reads past the
stack buffer and copies invalid data into the output buffer.

Fix this by detecting vsnprintf() failures and truncations before
appending to the output buffer, and report a fatal error instead of
producing corrupt symbol names.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260527-nova-exports-v2-1-06de4c556d55@nvidia.com
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
scripts/mod/modpost.c