Skip to contentSkip to conversation

2a10b8: libdtrace: resolve BTF type tags when importing BT...

oracle/dtrace Kris Van Hees 1 participant 1 message Aug 28

lore
Share & tools
lore

Kris Van Hees

author bot Reviewed-by Reviewed-by Reviewed-by Reviewed-by Reviewed-by Reviewed-by Reviewed-by
#0 lore raw

Branch: refs/heads/dev-queue
Home: https://github.com/oracle/dtrace
Commit: 2a10b8325f5d0c088ed895855fcef54148d0fe38

      https://github.com/oracle/dtrace/commit/2a10b8325f5d0c088ed895855fcef54148d0fe38

Author: Jacob Carlborg <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)

Changed paths:
M libdtrace/dt_btf.c

Log Message:
-----------
libdtrace: resolve BTF type tags when importing BTF into CTF

Without this fix, running any DTrace commands results in:

```
dtrace: invalid probe specifier ::::
"/usr/lib64/dtrace/6.12.0/procfs.d", line 131: operator -> cannot be
applied to pointer to type "void"; must be applied to a struct or
union pointer
```

The issue occurs on kernels which have BTF with type tags. The fix is to treat BTF_KIND_TYPE_TAG as a transparent modifier, resolving straight to type->type.

Commit: a4130f975ba04156acbf94a41e7891665191011e

      https://github.com/oracle/dtrace/commit/a4130f975ba04156acbf94a41e7891665191011e

Author: Jacob Carlborg <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)

Changed paths:
M libdtrace/io.d.in

Log Message:
-----------
libdtrace: derive io provider dev_name from the device model

Without this fix, running any DTrace commands, like dtrace -l, results in:

```
dtrace: invalid probe specifier :::: "/usr/lib64/dtrace/6.12.0/io.d",
line 134: failed to resolve vmlinux`major_names: Unknown symbol name
```

The issue is that on newer kernels the major_names symbols is not available in kallsyms anymore. For example, running grep -w major_names /proc/kallsyms on a newer kernel shows no results. Running the same command on an older kernel gives the following result:

```
$ grep -w major_names /proc/kallsyms
0000000000000000 b major_names
```

The fix is to stop depending on the major_names symbol and instead derive dev_name from the device model (the driver name), mirroring the struct buffer_head translator.

Commit: 4c4f4eec9b3a0e5147a3beab07556870e1036714

      https://github.com/oracle/dtrace/commit/4c4f4eec9b3a0e5147a3beab07556870e1036714

Author: Kris Van Hees <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)

Changed paths:
M libdtrace/dt_impl.h
M libdtrace/dt_open.c

Log Message:
-----------
libdtrace: determine (and store) non-initial PID namespace dev/ino

If dtrace is executing in a non-initial PID namespace, record the dev/ino pair to identify it. This can be used when performing pid/tgid lookups.

Commit: 3ccaaa2b58ddc9c278e1e7869cc4b9f0b511410b

      https://github.com/oracle/dtrace/commit/3ccaaa2b58ddc9c278e1e7869cc4b9f0b511410b

Author: Kris Van Hees <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)

Changed paths:
M libdtrace/dt_cg.c
M libdtrace/dt_cg.h

Log Message:
-----------
cg: provide function to retrieve pid and tgid in a PID ns agnostic way

The dt_cg_ns_pid_tgid() function automatically selects the correct BPF helper to get the proper pid and tgid values relative to the current PID namespace, and stores them in %r0 using the standard BPF convention:
(tgid << 32) | pid

Commit: 9361e7f00bb6f2a253800379c519ce16f5545eb4

      https://github.com/oracle/dtrace/commit/9361e7f00bb6f2a253800379c519ce16f5545eb4

Author: Jacob Carlborg <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)

Changed paths:
M libdtrace/dt_prov_dtrace.c

Log Message:
-----------
libdtrace: match BEGIN/END PID in the tracer's own PID namespace

Without this fix, running any probe hangs with no output, like dtrace -n 'BEGIN { trace("hi"); exit(0); }'.

The issues is that the BEGIN/END probes are implemented as uprobes on DTrace's own BEGIN_probe()/END_probe() functions in dt_work.c. bpf_get_current_pid_tgid() reports the TGID in the initial PID namespace, which does not match getpid() when DTrace runs inside a PID namespace. Using the --pid=host flag when running OrbStack does not help, because it shares the daemon's namespace, not the kernel init namespace. OrbStack's own supervisor runs in a nested PID namespace. On bare metal --pid=host does reach the init namespaces and the bug wouldn't appear.

This fix is when DTrace is in a non-initial PID namespace and the kernel is at least 5.7, use bpf_get_ns_current_pid_tgid instead of bpf_get_current_pid_tgid. bpf_get_ns_current_pid_tgid is namespace aware.

Commit: 1f5618797948616c6f45a9c003b5d70d702d1c73

      https://github.com/oracle/dtrace/commit/1f5618797948616c6f45a9c003b5d70d702d1c73

Author: Kris Van Hees <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)

Changed paths:
A test/unittest/pidns/common.bash
A test/unittest/pidns/test.x
A test/unittest/pidns/tst.begin.sh
A test/unittest/pidns/tst.concurrent.sh
A test/unittest/pidns/tst.disasm-helper.sh
A test/unittest/pidns/tst.end.sh
A test/unittest/pidns/tst.io-dev-name.sh
A test/unittest/pidns/tst.io-dev-name.x
A test/unittest/pidns/tst.proc-create.sh

Log Message:
-----------
test: add PID namespace support tests

Commit: 5a8f9f419d9e8cb89bc778b0ef68e4f5f8e54f4c

      https://github.com/oracle/dtrace/commit/5a8f9f419d9e8cb89bc778b0ef68e4f5f8e54f4c

Author: Kris Van Hees <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)

Changed paths:
M bpf/Build
A bpf/bvar_ns.c
M libdtrace/dt_bpf.c
M libdtrace/dt_cg.c
M libdtrace/dt_state.h
A test/unittest/pidns/tst.builtinvar-tid-pid.sh

Log Message:
-----------
bpf: make the PID ns dev/ino pair available to runtime BPF code

BPF code in generated probe programs needs to retrieve PID and TGID values in a PID ns aware manner if drace is running in a non-initial PID namespace.

Provide support for PID ns aware pid and tid built-in variable.

Compare: https://github.com/oracle/dtrace/compare/61fea621160e...5a8f9f419d9e

To unsubscribe from these emails, change your notification settings at https://github.com/oracle/dtrace/settings/notifications