HomeFreeBSD

sdt: Initialize probes in two passes

Description

sdt: Initialize probes in two passes

Suppose a kernel module A defines an SDT provider and probes, and kernel
linker file B, dependant on A, contains tracepoints for those probes.
When sdt.ko is loaded, it iterates over all loaded KLDs to initialize
probe structures and register them with dtrace. In particular it uses
linker_file_foreach(), which is not sorted; in the above scenario, B may
be visited before A. Thus, it's possible for sdt_kld_load_probes() to
try to add tracepoints to an uninitialized SDT probe.

An example of the above arises when pfsync, pf, and sdt are loaded in
that exact order after commit 4bb3b36577645.

Fix this by initializing probe structures in the first pass over loaded
KLDs. Then, the second pass can safely add tracepoints to any probe
structure.

Note that the scenario where B and A are loaded after sdt.ko is already
handled properly, as there, the kld_load eventhandler is responsible for
registering probes with dtrace, and that eventhandler fires for
dependencies before it does for the dependent KLD. This presumes,
however, that there are no cycles in the dependency graph.

Reported by: jenkins
MFC after: 2 weeks

Details

Provenance
markjAuthored on Jul 28 2025, 7:30 PM
Parents
rG9f0f30bc1f5f: libnvmf: Add nvmf_nqn_valid_strict() function
Branches
Unknown
Tags
Unknown