From: lzhan011 <redacted>
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 <redacted>
---
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