[for-next][PATCH 07/15] tracing/scripts: Check the section end before reading a string in tracing-update
From: Steven Rostedt
Date: Thu Nov 26 2026 - 11:25:25 EST
From: Leizhen Zhang <lzsx618@xxxxxxxxx>
for_each_shdr_str() evaluates strlen(str) before checking str < end, so
after the last string of the section it calls strlen() on the bytes just
past the section. Check the bound first.
Link: https://patch.msgid.link/20261008164117.3670267-2-lzsx618@xxxxxxxxx
Fixes: e30f8e61e251 ("tracing: Add a tracepoint verification check at build time")
Assisted-by: Claude:claude-opus-5-5 ASan
Signed-off-by: Leizhen Zhang <lzsx618@xxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
scripts/tracepoint-update.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/tracepoint-update.c b/scripts/tracepoint-update.c
index 5cf43c0aac89..c70c0b076554 100644
--- a/scripts/tracepoint-update.c
+++ b/scripts/tracepoint-update.c
@@ -74,7 +74,7 @@ static int add_string(const char *str, const char ***vals, int *count)
#define for_each_shdr_str(len, ehdr, sec) \
for (const char *str = (void *)(ehdr) + shdr_offset(sec), \
*end = str + shdr_size(sec); \
- len = strlen(str), str < end; \
+ str < end && (len = strlen(str), true); \
str += (len) + 1)
--
2.53.0