[PATCH v2 1/3] libdtrace: resolve BTF type tags transparently
Jacob Carlborg <[email protected]> Sat, 25 Jul 2026 20:04:07 +0200
| Newsgroups | dev.linux.lists.dtrace |
|---|---|
| Message-ID | <[email protected]> |
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`. Signed-off-by: Jacob Carlborg <[email protected]> --- v2: also handle BTF_KIND_TYPE_TAG as a transparent modifier in dt_btf_real_type_by_id() (per review feedback). libdtrace/dt_btf.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libdtrace/dt_btf.c b/libdtrace/dt_btf.c index 1f793397..3ec60dcb 100644 --- a/libdtrace/dt_btf.c +++ b/libdtrace/dt_btf.c @@ -672,10 +672,28 @@ dt_btf_add_to_ctf(dtrace_hdl_t *dtp, dt_btf_t *btf, ctf_dict_t *ctf, return ctfid == CTF_ERR ? dt_ctf_error(dtp, ctf) : ctfid; } + case BTF_KIND_TYPE_TAG: { + /* + * A type tag (e.g. __rcu, __user, __percpu) is a transparent + * annotation on the type it wraps. CTF has no equivalent, so + * we resolve straight through to the underlying type, just as + * we do for const/volatile/restrict. Treating it as ignored + * (mapping it to void) would leave every tagged member -- such + * as task_struct.real_parent (__rcu) -- resolving to "void", + * which breaks translator compilation on kernels whose BTF + * carries type tags. + */ + ctfid = dt_btf_add_to_ctf(dtp, btf, ctf, type->type); + if (ctfid == CTF_ERR) + return CTF_ERR; /* errno already set */ + + btf->ctfids[type_id] = ctfid; + + return ctfid; + } case BTF_KIND_VAR: case BTF_KIND_DATASEC: case BTF_KIND_DECL_TAG: - case BTF_KIND_TYPE_TAG: case BTF_KIND_ENUM64: case BTF_KIND_FUNC: return btf->ctfids[0]; /* Ignored for CTF */ @@ -860,6 +878,7 @@ dt_btf_real_type_by_id(dtrace_hdl_t *dtp, const dt_btf_t *btf, int32_t id) case BTF_KIND_RESTRICT: case BTF_KIND_TYPEDEF: case BTF_KIND_VOLATILE: + case BTF_KIND_TYPE_TAG: type = dt_btf_type_by_id(dtp, btf, type->type); default: return type; -- 2.50.1 (Apple Git-155)