On Tue, 22 Jul 2025 09:16:49 -0700 Linus Torvalds <torva...@linux-foundation.org> wrote:
> On Tue, 22 Jul 2025 at 08:21, Steven Rostedt <rost...@kernel.org> wrote: > > > > Add a verifier that injects a pointer to the tracepoint structure in the > > functions that are used and added to a section called __tracepoint_check. > > Then on boot up, iterate over this section and for every tracepoint > > descriptor that is pointed to, update its ".funcs" field to (void *)1, as > > the .funcs field is only set when a tracepoint is registered. At this > > time, no tracepoints should be registered. > > Why? > > Doing this at runtime seems completely bass-ackwards. > > If you want to do this verification, why don't you do it at build-time? The second patch does that, but is much more complex due to having to parse the elf file. It hooks into the sorttable code as that already does most of the parsing that was needed. It uses the same trick as the runtime verifier by checking tracepoints against the __tracepoint_check section (but not with the '.func' test, but instead it sorts it and does a binary search). I kept this to verify that the build time worked too, as the runtime check is so much simpler and easier to implement. Basically, I use this to verify that the build time works. That's why if you enable this it will select the build time version. It was used to catch bugs in the build version as I developed it. And currently neither tests modules (I run this against an allyesconfig), but the runtime version could easily be modified to test modules too, whereas the build time would require adding another elf parser as the sorttable isn't run on module code. I can remove the runtime check if you prefer. -- Steve