mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] tracepoint-update: do not reuse section pointers from a previous file
@ 2026-10-05 10:41 lzhan011
  2026-10-05 10:42 ` [PATCH 2/2] tracepoint-update: check the section end before reading a string lzhan011
  0 siblings, 1 reply; 2+ messages in thread
From: lzhan011 @ 2026-10-05 10:41 UTC (permalink / raw)
  To: rostedt, mhiramat, mathieu.desnoyers; +Cc: linux-trace-kernel, linux-kernel

From: lzhan011 <zhangleizhen645@gmail.com>

check_data_sec and tracepoint_data_sec are static and set while scanning
the section headers in process_tracepoints(), but are never reset. When
tracepoint-update is given several files and a later file lacks these
sections, the pointers from the previous, already unmapped file are
used, which crashes:

  $ scripts/tracepoint-update --module a.o c.o
  AddressSanitizer: SEGV ...

Reset both pointers at the start of process_tracepoints().

Kbuild currently passes a single file per invocation, so this does not
affect normal builds.

Fixes: e30f8e61e251 ("tracing: Add a tracepoint verification check at build time")
Assisted-by: Claude:claude-opus-5-5 ASan UBSan
Signed-off-by: lzhan011 <zhangleizhen645@gmail.com>
---
 scripts/tracepoint-update.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/tracepoint-update.c b/scripts/tracepoint-update.c
index 5cf43c0aa..4c4b66901 100644
--- a/scripts/tracepoint-update.c
+++ b/scripts/tracepoint-update.c
@@ -163,6 +163,10 @@ static int process_tracepoints(bool mod, void *addr, const char *fname)
 	int idx;
 	int done = 2;
 
+	/* Do not use the sections of a previously processed file */
+	check_data_sec = NULL;
+	tracepoint_data_sec = NULL;
+
 	shdr_start = (Elf_Shdr *)((char *)ehdr + ehdr_shoff(ehdr));
 	shentsize = ehdr_shentsize(ehdr);
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] tracepoint-update: check the section end before reading a string
  2026-10-05 10:41 [PATCH 1/2] tracepoint-update: do not reuse section pointers from a previous file lzhan011
@ 2026-10-05 10:42 ` lzhan011
  0 siblings, 0 replies; 2+ messages in thread
From: lzhan011 @ 2026-10-05 10:42 UTC (permalink / raw)
  To: rostedt, mhiramat, mathieu.desnoyers; +Cc: linux-trace-kernel, linux-kernel

From: lzhan011 <zhangleizhen645@gmail.com>

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.

Fixes: e30f8e61e251 ("tracing: Add a tracepoint verification check at build time")
Assisted-by: Claude:claude-opus-5-5 ASan
Signed-off-by: lzhan011 <zhangleizhen645@gmail.com>
---
 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 4c4b66901..ad5f691c1 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.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-05 10:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 10:41 [PATCH 1/2] tracepoint-update: do not reuse section pointers from a previous file lzhan011
2026-10-05 10:42 ` [PATCH 2/2] tracepoint-update: check the section end before reading a string lzhan011

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®