]> exis.tech > repos - linux.git/commit
tracing/probes: Fix potential underflow in LEN_OR_ZERO macro
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Mon, 20 Jul 2026 10:12:29 +0000 (19:12 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Tue, 21 Jul 2026 01:23:17 +0000 (10:23 +0900)
commit8ce20bfba48902e1382187cd1a852f7cf3a1e739
treefb040eb6ed2f5f03519ff8ab950d4c779b23a9ce
parenta9d6fb284039a5d3858a1d9f9a0d7e46cfb7c2d4
tracing/probes: Fix potential underflow in LEN_OR_ZERO macro

In __set_print_fmt(), LEN_OR_ZERO is defined as (len ? len - pos : 0).
If len is non-zero but smaller than pos, len - pos evaluates to a negative
integer. When passed as a size argument to snprintf(), this negative value
is cast to a large unsigned size_t, bypassing buffer size limits.

Ensure len > pos before subtracting to avoid integer underflow.

Link: https://lore.kernel.org/all/178454234934.290363.15247317871499514139.stgit@devnote2/
Fixes: 5bf652aaf46c ("tracing/probes: Integrate duplicate set_print_fmt()")
Cc: stable@vger.kernel.org
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
kernel/trace/trace_probe.c