Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Leizhen Zhang <lzsx618@gmail.com>
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracepoint-update: bound section names by the section name table
Date: Mon, 19 Oct 2026 09:53:02 -0400	[thread overview]
Message-ID: <20261019095302.5a4aa377@gandalf.local.home> (raw)
In-Reply-To: <20261019000419.3977860-1-lzsx618@gmail.com>

On Sun, 18 Oct 2026 19:04:19 -0500
Leizhen Zhang <lzsx618@gmail.com> wrote:

> process_tracepoints() finds its two sections by name:
> 
> 	secstrings = (const char *)ehdr + shdr_offset(string_sec);
> 	...
> 		idx = shdr_name(shdr);
> 		if (!strcmp(secstrings + idx, "__tracepoint_check")) {
> 
> sh_name is a 32-bit offset read from the file and nothing bounds it, so one
> section header can point the name anywhere and strcmp() reads from there.
> 
> Found by fuzzing the host ELF tools with mutated object files under
> ASan/UBSan. Reproducer, setting only sh_name of section 1 in an otherwise
> valid .o:
> 
>   $ python3 -c 'import struct
>   d = bytearray(open("tiny.o","rb").read())
>   shoff, = struct.unpack_from("<Q", d, 0x28)
>   entsize, = struct.unpack_from("<H", d, 0x3a)
>   struct.pack_into("<I", d, shoff + entsize, 0x7ffffff0)
>   open("t.o","wb").write(bytes(d))'
> 
>   $ ./tracepoint-update t.o
>   ERROR: AddressSanitizer: SEGV on unknown address 0x7f8d689ae848
>     #0 in strcmp
>     #1 in process_tracepoints scripts/tracepoint-update.c
> 
> Skip a section whose name offset is outside the name table. Such a section
> is neither __tracepoint_check nor __tracepoints_strings, so skipping it
> changes nothing for a valid object: the reproducer and an unmodified object
> now both print the same "no __tracepoint_check in file" line and exit 1.
> 
> This bounds the index into the table, not the table itself: a name table
> whose own sh_offset or sh_size is bogus is a separate gap, and in the
> elf_map() path used here there is no mapped size to check it against.
> 
> Fixes: e30f8e61e251 ("tracing: Add a tracepoint verification check at build time")

This is not a fix. This is just passing a corrupt object file into the
build tooling and showing that it fails.

Show me that this can be triggered by a legitimate object file and then I
would consider it. Otherwise, you are chasing made up bugs.

-- Steve


> Assisted-by: LLM ASan UBSan
> Signed-off-by: Leizhen Zhang <lzsx618@gmail.com>
> ---
>  scripts/tracepoint-update.c | 5 +++++

      reply	other threads:[~2026-10-19 13:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19  0:04 [PATCH] tracepoint-update: bound section names by the section name table Leizhen Zhang
2026-10-19 13:53 ` Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019095302.5a4aa377@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lzsx618@gmail.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox