tracing: Fix use-after-free on field name/type of dynamic probe events
PATCH 1/1 tracing: Fix use-after-free on field name/type of dynamic probe events
Fields of a probe-based dynamic event (kprobe, uprobe and eprobe events) are created from the argument name and type strings of the trace_probe that first registers the event, as plain pointer references without copying.
When several probes are appended to the same event, they share the trace_event_call and its field list, which stays the one defined by the primary probe. Deleting just the primary probe with "-:group/event symbol" frees the trace_probe and its argument strings, while the event call is kept registered by the remaining sibling probes. field->name and field->type are left dangling, and any field lookup - e.g. writing to events/<grp>/<ev>/filter - reads freed memory:
BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call trace: trace_find_event_field+0xd6/0x220 parse_pred process_preds create_filter apply_event_filter event_filter_write
Make the field own its strings: duplicate name and type with kstrdup_const() in __trace_define_field() and release them with kfree_const() in trace_destroy_fields(). Fields of static trace events still reference their kernel/module rodata string literals directly, as kstrdup_const()/kfree_const() only touch memory that was actually allocated.
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
--- kernel/trace/trace_events.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/trace/trace_events.c +14 -2
@@ -123,8 +123,18 @@ static int __trace_define_field(struct list_head *head, const char *type,if (!field)return -ENOMEM ; - field->name = name; - field->type = type; + field->name =kstrdup_const (name,GFP_TRACE ); +if (!field->name) { +kmem_cache_free (field_cachep, field); +return -ENOMEM ; + } + + field->type =kstrdup_const (type,GFP_TRACE ); +if (!field->type) { +kfree_const (field->name); +kmem_cache_free (field_cachep, field); +return -ENOMEM ; + }if (filter_type ==FILTER_OTHER ) field->filter_type =filter_assign_type (type);
@@ -225,6 +235,8 @@ static void trace_destroy_fields(struct trace_event_call *call) head =trace_get_fields (call);list_for_each_entry_safe (field, next, head, link) {list_del (&field->link); +kfree_const (field->name); +kfree_const (field->type);kmem_cache_free (field_cachep, field); } }
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] The commit message claims that fields of static trace events reference their kernel or module rodata string literals directly without allocation, but module strings are unconditionally duplicated.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but if a user_event's destruction fails because the trace event is busy, its fields are irreversibly destroyed, leaving the active event in a corrupted state. --
--- Patch [1]: [PATCH] tracing: Fix use-after-free on field name/type of dynamic probe events --- commit cf6ec74d4b06c238fc3f0cc0f2463ea2e1435590
Author: Henry Martin <[email protected]>
tracing: Fix use-after-free on field name/type of dynamic probe events
This commit modifies dynamic event trace field registration to duplicate field name and type strings using kstrdup_const(). This ensures the field owns its strings and prevents use-after-free bugs when primary probes are deleted but event calls remain active.
Quoted 7 lines
kernel/trace/trace_events.c +0
-0@@ -122,8 +122,18 @@ static int __trace_define_field(struct list_head *head, const char *type,if (!field)return -ENOMEM ;
kernel/trace/trace_events.c static int __trace_define_field(struct list_head *head, const char *type, · line 131
Quoted 10 lines
kernel/trace/trace_events.c +7
-2- field->name = name; - field->type = type; + field->name =kstrdup_const (name,GFP_TRACE ); +if (!field->name) { +kmem_cache_free (field_cachep, field); +return -ENOMEM ; + } + + field->type =kstrdup_const (type,GFP_TRACE );
[Severity: Medium]
The commit message states that fields of static trace events reference their kernel or module rodata string literals directly, as kstrdup_const() only touches allocated memory.
Does kstrdup_const() actually handle module rodata this way? Looking at kstrdup_const(), it delegates to is_kernel_rodata(), which only checks core kernel boundaries.
Won't this cause module trace events to unconditionally duplicate their name and type strings instead of referencing the module rodata?
kernel/trace/trace_events.c static int __trace_define_field(struct list_head *head, const char *type, · line 139
Quoted 7 lines
kernel/trace/trace_events.c +5
-0+if (!field->type) { +kfree_const (field->name); +kmem_cache_free (field_cachep, field); +return -ENOMEM ; + }if (filter_type ==FILTER_OTHER )
[ ... ]
While reviewing the string lifecycle in trace events, a related preexisting issue in user events was identified:
kernel/trace/trace_events_user.c:destroy_user_event() {
...
/* Must destroy fields before call removal */
user_event_destroy_fields(user);
ret = user_event_set_call_visible(user, false);
if (ret)
return ret;
...
}[Severity: High]
This isn't a bug introduced by this patch, but if a user_event's destruction fails because the trace event is busy (user_event_set_call_visible() returns -EBUSY), the event's fields are already irreversibly destroyed.
Will this leave the active event in a corrupted state, where any subsequent interactions with this event operate on an empty field list?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Steven Rostedt
maintainerQuoted 8 lines · On Mon, 24 Aug 2026 15:10:11 +0800 Henry Martin <[email protected]>…
Fields of a probe-based dynamic event (kprobe, uprobe and eprobe events) are created from the argument name and type strings of the
trace_probethat first registers the event, as plain pointer references without copying.When several probes are appended to the same event, they share the
trace_event_calland its field list, which stays the one defined by the primary probe. Deleting just the primary probe with
What do you mean by "appended to the same event"? Do you mean eprobes?
Can you post a reproducer for this?
Quoted 15 lines
"-:group/event symbol" frees the
trace_probeand its argument strings, while the event call is kept registered by the remaining sibling probes.field->nameandfield->typeare left dangling, and any field lookup - e.g. writing to events/<grp>/<ev>/filter - reads freed memory:BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call trace: trace_find_event_field+0xd6/0x220 parse_pred process_preds create_filter apply_event_filter event_filter_write
Quoted 6 lines
Make the field own its strings: duplicate name and type with
kstrdup_const()in__trace_define_field()and release them withkfree_const()intrace_destroy_fields(). Fields of static trace events still reference their kernel/module rodata string literals directly, as kstrdup_const()/kfree_const() only touch memory that was actually allocated.
Wrong fix.
kernel/trace/trace_events.c
Quoted 14 lines
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
Fixes ca89bc071d5e4 ("tracing/kprobe: Add multi-probe per event support")Signed-off-by Henry Martin <[email protected]>--- kernel/trace/trace_events.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)kernel/trace/trace_events.c +0
-0
This is a bug with trace_probes.c and not trace_events.c. This should be fixed without touching trace_events.c. That is, the trace_probes.c code (or trace_eprobes.c if it's only affects eprobes) should handle this issue.
If you had an example, I could have figured out exactly where to place the fix.
-- Steve
Quoted 30 lines
kernel/trace/trace_events.c +14
-2@@ -123,8 +123,18 @@ static int __trace_define_field(struct list_head *head, const char *type,if (!field)return -ENOMEM ; - field->name = name; - field->type = type; + field->name =kstrdup_const (name,GFP_TRACE ); +if (!field->name) { +kmem_cache_free (field_cachep, field); +return -ENOMEM ; + } + + field->type =kstrdup_const (type,GFP_TRACE ); +if (!field->type) { +kfree_const (field->name); +kmem_cache_free (field_cachep, field); +return -ENOMEM ; + }if (filter_type ==FILTER_OTHER ) field->filter_type =filter_assign_type (type);@@ -225,6 +235,8 @@ static void trace_destroy_fields(struct trace_event_call *call) head =trace_get_fields (call);list_for_each_entry_safe (field, next, head, link) {list_del (&field->link); +kfree_const (field->name); +kfree_const (field->type);kmem_cache_free (field_cachep, field); } }
PATCH v3 1/1 tracing/probes: Fix use-after-free on field name/type of multi-probe events
The fields of a probe-based dynamic event (kprobe, uprobe, eprobe and fprobe events) are created in traceprobe_define_arg_fields() by handing the probe_arg name/type strings to trace_define_field(), which only stores the pointers without copying. Those strings are owned by the trace_probe and are freed when that probe is removed.
An event can hold several probes ("multi-probe per event", added by the
Fixes: commit below). The field list is defined only once, by the first probe that registers the event, but it is kept alive by any surviving sibling probe. Deleting just that first probe by symbol -
# primary A: fields are defined from A's args echo 'p:kprobes/ev vfs_read a1=$arg1' > kprobe_events # append B: shares A's event call echo 'p:kprobes/ev vfs_write a1=$arg1' >> kprobe_events # delete only A (matched by symbol), B survives echo '-:kprobes/ev vfs_read' >> kprobe_events
frees A's args (trace_probe_cleanup() -> traceprobe_free_probe_arg()), but trace_probe_unlink() keeps the trace_probe_event because the probe list is not empty. The event call stays registered via B while its fields now reference freed memory. Any field lookup then reads it, e.g.
echo 'a1 == 1' > events/kprobes/ev/filter
BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call Trace: strcmp trace_find_event_field parse_pred process_preds create_filter apply_event_filter event_filter_write
field->name references parg->name (kstrdup'd, freed with the probe) and, for array arguments, field->type references parg->fmt (kmalloc'd, freed with the probe) - the scalar type otherwise points at the static fmttype rodata, which is safe.
Fix it in the probe layer, which is where the borrowing happens, so that trace_define_field() and static trace events are left untouched. Make traceprobe_define_arg_fields() duplicate the name and type strings and have the trace_probe_event - which embeds the event call and outlives every individual probe - own the copies, releasing them in trace_probe_event_free().
The reproducer above triggers reliably; the field lookup and the delete both run under event_mutex, so this is a dangling reference after removal rather than a race.
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
---
v3:
- Steve: wrong fix / wrong file. Move the fix out of trace_events.c into the probe layer (traceprobe_define_arg_fields() / trace_probe_event_free()) so trace_define_field() and static events are untouched. Ownership now lives on trace_probe_event, whose lifetime matches the event call and its field list.
- Clarify in the changelog that this is kprobe multi-probe-per-event (append_trace_kprobe), not eprobes, and add a shell reproducer.
v2:
- Reworded the module-rodata note (dropped, superseded by v3).
kernel/trace/trace_probe.c | 36 +++++++++++++++++++++++++++++++++++- kernel/trace/trace_probe.h | 2 ++ 2 files changed, 37 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +35 -1
@@ -2552,19 +2552,48 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For a +* multi-probe event the field list is defined once by the first probe +* but kept alive by the surviving siblings, so removing that first +* probe would leave the fields referencing freed memory. Make the +* event own duplicates that live as long as the event call itself. +*/ +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret =trace_define_field (event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ; + } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER );
@@ -2576,6 +2605,11 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,static void trace_probe_event_free (struct trace_probe_event *tpe) { +int i; + +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings);kfree (tpe->class.system);kfree (tpe->call.name);kfree (tpe->call.print_fmt);
kernel/trace/trace_probe.h +2 -0
@@ -264,6 +264,8 @@ struct trace_probe_event {struct trace_event_call call;struct list_head files;struct list_head probes; +char **field_strings; +int nr_field_strings;struct trace_uprobe_filter filter[]; };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3] tracing/probes: Fix use-after-free on field name/type of multi-probe events
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Error handling in `traceprobe_define_arg_fields()` does not clean up `tpe->field_strings` or reset…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Error handling in traceprobe_define_arg_fields() does not clean up tpe->field_strings or reset tpe->nr_field_strings on failure, leading to a memory leak, slab out-of-bounds write, and arbitrary free upon retry. --
--- Patch [1]: [PATCH v3] tracing/probes: Fix use-after-free on field name/type of multi-probe events --- commit b40c9f727280d82f97af5f38c001f0fd57efcf5e
Author: Henry Martin <[email protected]>
tracing/probes: Fix use-after-free on field name/type of multi-probe events
This commit addresses a use-after-free issue where an event's fields might reference freed memory after one of its probes is removed. It fixes this by allocating a duplicate set of name and type strings directly owned by the trace_probe_event, ensuring they outlive any individual probe.
Quoted 46 lines
kernel/trace/trace_probe.c +25
-1@@ -965,19 +965,48 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For a +* multi-probe event the field list is defined once by the first probe +* but kept alive by the surviving siblings, so removing that first +* probe would leave the fields referencing freed memory. Make the +* event own duplicates that live as long as the event call itself. +*/ +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret = trace_define_field(event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ;
kernel/trace/trace_probe.c int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype
Quoted 10 lines
kernel/trace/trace_probe.c +7
-0+ } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER ); +if (ret) +return ret;
[Severity: High]
If trace_define_field() fails, does this error path leak the newly allocated strings and the tpe->field_strings array?
Looking at event_define_fields() in kernel/trace/trace_events.c, the return value from this function is ignored:
if (field->type == TRACE_FUNCTION_TYPE) {
field->define_fields(call);
break;
}Since the return value is ignored and the event's field list remains empty if the first argument fails, couldn't the system invoke this function again on retry if there are multiple trace array instances?
If it is retried, the initial kcalloc() unconditionally overwrites tpe->field_strings, leaking the old array.
Additionally, since tpe->nr_field_strings is not reset on failure, wouldn't a retry start appending string pointers out of bounds of the new array? This appears like it could eventually cause trace_probe_event_free() to read out-of-bounds pointers and pass them to kfree().
Quoted 3 lines
kernel/trace/trace_probe.c +0
-0}return 0 ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Steven Rostedt
maintainerRe: [PATCH v3] tracing/probes: Fix use-after-free on field name/type of multi-probe events
Quoted 73 lines · On Tue, 25 Aug 2026 11:37:13 +0000 [email protected] wrote:
Quoted 46 lines
kernel/trace/trace_probe.c +25
-1@@ -965,19 +965,48 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For a +* multi-probe event the field list is defined once by the first probe +* but kept alive by the surviving siblings, so removing that first +* probe would leave the fields referencing freed memory. Make the +* event own duplicates that live as long as the event call itself. +*/ +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret = trace_define_field(event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ;kernel/trace/trace_probe.c int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype
Quoted 10 lines
kernel/trace/trace_probe.c +7
-0+ } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER ); +if (ret) +return ret;[Severity: High]
Iftrace_define_field()fails, does this error path leak the newly allocated strings and thetpe->field_stringsarray?Looking at
event_define_fields()inkernel/trace/trace_events.c, the return value from this function is ignored:if (field->type == TRACE_FUNCTION_TYPE) { field->define_fields(call); break; }Since the return value is ignored and the event's field list remains empty if the first argument fails, couldn't the system invoke this function again on retry if there are multiple trace array instances?
Quoted 8 lines
If it is retried, the initial
kcalloc()unconditionally overwritestpe->field_strings, leaking the old array.Additionally, since
tpe->nr_field_stringsis not reset on failure, wouldn't a retry start appending string pointers out of bounds of the new array? This appears like it could eventually causetrace_probe_event_free()to read out-of-bounds pointers and pass them tokfree().
The above looks legit too. Please address it.
-- Steve
Quoted 4 lines
Quoted 3 lines
kernel/trace/trace_probe.c +0
-0}return 0 ; }
PATCH v4 1/1 tracing/probes: Fix use-after-free on field name/type of events with multiple probes
The fields of a probe-based dynamic event (kprobe, uprobe, eprobe and fprobe events) are created in traceprobe_define_arg_fields() by handing the probe_arg name/type strings to trace_define_field(), which only stores the pointers without copying. Those strings are owned by the trace_probe and are freed when that probe is removed.
An event can have several probes attached. The field list is defined only once, by the first probe that registers the event, but it is kept alive by any surviving sibling probe. Deleting just that first probe by symbol -
# primary A: fields are defined from A's args echo 'p:kprobes/ev vfs_read a1=$arg1' > kprobe_events # append B: shares A's event call echo 'p:kprobes/ev vfs_write a1=$arg1' >> kprobe_events # delete only A (matched by symbol), B survives echo '-:kprobes/ev vfs_read' >> kprobe_events
frees A's args (trace_probe_cleanup() -> traceprobe_free_probe_arg()), but trace_probe_unlink() keeps the trace_probe_event because the probe list is not empty. The event call stays registered via B while its fields now reference freed memory. Any field lookup then reads it, e.g.
echo 'a1 == 1' > events/kprobes/ev/filter
BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call Trace: strcmp trace_find_event_field parse_pred process_preds create_filter apply_event_filter event_filter_write
field->name references parg->name (kstrdup'd, freed with the probe) and, for array arguments, field->type references parg->fmt (kmalloc'd, freed with the probe) - the scalar type otherwise points at the static fmttype rodata, which is safe.
Have traceprobe_define_arg_fields() duplicate the name and type strings and anchor the copies on the trace_probe_event, which embeds the event call and outlives every individual probe; trace_probe_event_free() releases them.
The reproducer above triggers reliably; the field lookup and the delete both run under event_mutex, so this is a dangling reference after removal rather than a race.
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
---
v4:
- Drop the redundant "added by the Fixes: commit below" and reword the code comment ("an event with multiple probes attached"; clearer last sentence), per Steve's review.
- Steve: drop the sentence explaining the move from the previous version from the changelog.
- sashiko-bot (ack'd by Steve): traceprobe_define_arg_fields() may be called again after a failed first attempt, since event_define_fields() ignores this hook's return value. Freeing and resetting the leftover duplicates at entry avoids leaking the previous array and writing past the new one.
v3:
- Move the fix out of trace_events.c into the probe layer (traceprobe_define_arg_fields()/trace_probe_event_free()). Ownership lives on trace_probe_event, whose lifetime matches the field list.
- Clarify this is kprobe multi-probe-per-event, not eprobes, and add a shell reproducer.
v2:
- Changelog wording (superseded by v3).
kernel/trace/trace_probe.c | 48 ++++++++++++++++++++++++++++++++++++- kernel/trace/trace_probe.h | 2 ++ 2 files changed, 49 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +47 -1
@@ -2552,19 +2552,60 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For an +* event with multiple probes attached, the field list is defined +* once by the first probe but kept alive by the surviving siblings, +* so removing that first probe would leave the fields referencing +* freed memory. Duplicate the strings and anchor the copies on the +* trace_probe_event, which lives as long as the field list itself. +* +* event_define_fields() ignores the return value of this hook, so +* if a previous attempt failed before creating any field, it may +* call here again. Release duplicates left behind by such an +* attempt before starting over. +*/ +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings); + tpe->field_strings =NULL ; + tpe->nr_field_strings =0 ; + +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret =trace_define_field (event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ; + } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER );
@@ -2576,6 +2617,11 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,static void trace_probe_event_free (struct trace_probe_event *tpe) { +int i; + +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings);kfree (tpe->class.system);kfree (tpe->call.name);kfree (tpe->call.print_fmt);
kernel/trace/trace_probe.h +2 -0
@@ -264,6 +264,8 @@ struct trace_probe_event {struct trace_event_call call;struct list_head files;struct list_head probes; +char **field_strings; +int nr_field_strings;struct trace_uprobe_filter filter[]; };
Signature · 1 line
2.43.0
Masami Hiramatsu (Google)
maintainerRe: [PATCH v4] tracing/probes: Fix use-after-free on field name/type of events with multiple probes
Quoted 49 lines · On Wed, 26 Aug 2026 11:00:09 +0800 Henry Martin <[email protected]>…
The fields of a probe-based dynamic event (kprobe, uprobe, eprobe and fprobe events) are created in
traceprobe_define_arg_fields()by handing theprobe_argname/type strings totrace_define_field(), which only stores the pointers without copying. Those strings are owned by thetrace_probeand are freed when that probe is removed.An event can have several probes attached. The field list is defined only once, by the first probe that registers the event, but it is kept alive by any surviving sibling probe. Deleting just that first probe by symbol -
# primary A: fields are defined from A's args echo 'p:kprobes/ev vfs_read a1=$arg1' > kprobe_events # append B: shares A's event call echo 'p:kprobes/ev vfs_write a1=$arg1' >> kprobe_events # delete only A (matched by symbol), B survives echo '-:kprobes/ev vfs_read' >> kprobe_eventsfrees A's args (
trace_probe_cleanup()->traceprobe_free_probe_arg()), buttrace_probe_unlink()keeps thetrace_probe_eventbecause the probe list is not empty. The event call stays registered via B while its fields now reference freed memory. Any field lookup then reads it, e.g.echo 'a1 == 1' > events/kprobes/ev/filter
BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call Trace: strcmp trace_find_event_field parse_pred process_preds create_filter apply_event_filter event_filter_write
field->namereferencesparg->name(kstrdup'd, freed with the probe) and, for array arguments,field->typereferencesparg->fmt(kmalloc'd, freed with the probe) - the scalar type otherwise points at the static fmttype rodata, which is safe.Have
traceprobe_define_arg_fields()duplicate the name and type strings and anchor the copies on thetrace_probe_event, which embeds the event call and outlives every individual probe;trace_probe_event_free()releases them.The reproducer above triggers reliably; the field lookup and the delete both run under
event_mutex, so this is a dangling reference after removal rather than a race.
Quoted 5 lines
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
Fixes ca89bc071d5e4 ("tracing/kprobe: Add multi-probe per event support")Signed-off-by Henry Martin <[email protected]>
Thanks! this looks good to me.
Hmm, maybe I need to update kselftest to check this issue. Since the current multiprobe test case does not set any argument, this was not caught. I have checked this patch with below update.
Let me pick this fix.
Thank you,
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_multiprobe.tc +24 -0
@@ -30,3 +30,27 @@ cat kprobe_events | grep "$DEF2" :;: "Appending different type must fail" ;: ! echo "$DEF1 \$stack" >> kprobe_events + +:;: "Remove remaining probe" ;: +echo "-:$EVENT_NAME" >> kprobe_events + +:;: "Define multiprobe with arguments and verify format and filter after primary removal" ;: +DEF1_ARG="p:$EVENT_NAME $SYM1 a1=\$stack" +DEF2_ARG="p:$EVENT_NAME $SYM2 a1=\$stack" +echo $DEF1_ARG >> kprobe_events +echo $DEF2_ARG >> kprobe_events + +# Remove primary probe that defined the fields +echo "-:$EVENT_NAME $SYM1" >> kprobe_events +grep -q "$DEF2_ARG" kprobe_events +! grep -q "$DEF1_ARG" kprobe_events + +# Verify format and filter on remaining event (reads field->name and field->type) +cat events/$EVENT_NAME/format > /dev/null +echo 'a1 == 0' > events/$EVENT_NAME/filter +echo 0 > events/$EVENT_NAME/filter + +# Clean up +echo "-:$EVENT_NAME" >> kprobe_events +test `cat kprobe_events | wc -l` -eq 0 +
Thanks,
Quoted 118 lines
---
v4:
- Drop the redundant "added by the Fixes: commit below" and reword the code comment ("an event with multiple probes attached"; clearer last sentence), per Steve's review.
- Steve: drop the sentence explaining the move from the previous version from the changelog.
- sashiko-bot (ack'd by Steve):traceprobe_define_arg_fields()may be called again after a failed first attempt, sinceevent_define_fields()ignores this hook's return value. Freeing and resetting the leftover duplicates at entry avoids leaking the previous array and writing past the new one.
v3:
- Move the fix out oftrace_events.cinto the probe layer (traceprobe_define_arg_fields()/trace_probe_event_free()). Ownership lives ontrace_probe_event, whose lifetime matches the field list.
- Clarify this is kprobe multi-probe-per-event, not eprobes, and add a shell reproducer.
v2:
- Changelog wording (superseded by v3).kernel/trace/trace_probe.c | 48 ++++++++++++++++++++++++++++++++++++- kernel/trace/trace_probe.h | 2 ++ 2 files changed, 49 insertions(+), 1 deletion(-)kernel/trace/trace_probe.c +47
-1@@ -2552,19 +2552,60 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For an +* event with multiple probes attached, the field list is defined +* once by the first probe but kept alive by the surviving siblings, +* so removing that first probe would leave the fields referencing +* freed memory. Duplicate the strings and anchor the copies on the +* trace_probe_event, which lives as long as the field list itself. +* +* event_define_fields() ignores the return value of this hook, so +* if a previous attempt failed before creating any field, it may +* call here again. Release duplicates left behind by such an +* attempt before starting over. +*/ +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings); + tpe->field_strings =NULL ; + tpe->nr_field_strings =0 ; + +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret =trace_define_field (event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ; + } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER );@@ -2576,6 +2617,11 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,static void trace_probe_event_free (struct trace_probe_event *tpe) { +int i; + +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings);kfree (tpe->class.system);kfree (tpe->call.name);kfree (tpe->call.print_fmt);kernel/trace/trace_probe.h +2
-0@@ -264,6 +264,8 @@ struct trace_probe_event {struct trace_event_call call;struct list_head files;struct list_head probes; +char **field_strings; +int nr_field_strings;struct trace_uprobe_filter filter[]; };Signature · 1 line
2.43.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Re: [PATCH v3] tracing/probes: Fix use-after-free on field name/type of multi-probe events
In reply to Steven Rostedt[1]: <[email protected]>
Thanks,
-- Henry
Quoted 96 lines · Steven Rostedt <[email protected]> 于2026年8月25日周二 22:21写道:
Quoted 73 lines · On Tue, 25 Aug 2026 11:37:13 +0000 [email protected] wrote:
Quoted 46 lines
kernel/trace/trace_probe.c +25
-1@@ -965,19 +965,48 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For a +* multi-probe event the field list is defined once by the first probe +* but kept alive by the surviving siblings, so removing that first +* probe would leave the fields referencing freed memory. Make the +* event own duplicates that live as long as the event call itself. +*/ +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret = trace_define_field(event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ;kernel/trace/trace_probe.c int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype
Quoted 10 lines
kernel/trace/trace_probe.c +7
-0+ } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER ); +if (ret) +return ret;[Severity: High]
Iftrace_define_field()fails, does this error path leak the newly allocated strings and thetpe->field_stringsarray?Looking at
event_define_fields()inkernel/trace/trace_events.c, the return value from this function is ignored:if (field->type == TRACE_FUNCTION_TYPE) { field->define_fields(call); break; }Since the return value is ignored and the event's field list remains empty if the first argument fails, couldn't the system invoke this function again on retry if there are multiple trace array instances?
Quoted 8 lines
If it is retried, the initial
kcalloc()unconditionally overwritestpe->field_strings, leaking the old array.Additionally, since
tpe->nr_field_stringsis not reset on failure, wouldn't a retry start appending string pointers out of bounds of the new array? This appears like it could eventually causetrace_probe_event_free()to read out-of-bounds pointers and pass them tokfree().The above looks legit too. Please address it.
-- Steve
Quoted 4 lines
Quoted 3 lines
} return 0;}
Steven Rostedt
maintainerRe: [PATCH v3] tracing/probes: Fix use-after-free on field name/type of multi-probe events
In reply to Henry MartinQuoted 8 lines · On Tue, 25 Aug 2026 19:12:10 +0800 Henry Martin <[email protected]>…
The fields of a probe-based dynamic event (kprobe, uprobe, eprobe and fprobe events) are created in
traceprobe_define_arg_fields()by handing theprobe_argname/type strings totrace_define_field(), which only stores the pointers without copying. Those strings are owned by thetrace_probeand are freed when that probe is removed.An event can hold several probes ("multi-probe per event", added by the
Fixes: commit below).
You can remove the ", added by the Fixes: commit below" as that is already assumed when there's a Fixes tag.
Quoted 28 lines
The field list is defined only once, by the first
probe that registers the event, but it is kept alive by any surviving sibling probe. Deleting just that first probe by symbol -# primary A: fields are defined from A's args echo 'p:kprobes/ev vfs_read a1=$arg1' > kprobe_events # append B: shares A's event call echo 'p:kprobes/ev vfs_write a1=$arg1' >> kprobe_events # delete only A (matched by symbol), B survives echo '-:kprobes/ev vfs_read' >> kprobe_eventsfrees A's args (
trace_probe_cleanup()->traceprobe_free_probe_arg()), buttrace_probe_unlink()keeps thetrace_probe_eventbecause the probe list is not empty. The event call stays registered via B while its fields now reference freed memory. Any field lookup then reads it, e.g.echo 'a1 == 1' > events/kprobes/ev/filter
BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call Trace: strcmp trace_find_event_field parse_pred process_preds create_filter apply_event_filter event_filter_write
Quoted 7 lines
field->namereferencesparg->name(kstrdup'd, freed with the probe) and, for array arguments,field->typereferencesparg->fmt(kmalloc'd, freed with the probe) - the scalar type otherwise points at the static fmttype rodata, which is safe.Fix it in the probe layer, which is where the borrowing happens, so that
trace_define_field()and static trace events are left untouched. Make
You can remove that first sentence. It's not useful information for this commit. It's just stating why you changed it from a previous version.
Quoted 36 lines
traceprobe_define_arg_fields()duplicate the name and type strings and have thetrace_probe_event- which embeds the event call and outlives every individual probe - own the copies, releasing them intrace_probe_event_free().The reproducer above triggers reliably; the field lookup and the delete both run under
event_mutex, so this is a dangling reference after removal rather than a race.The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
Fixes ca89bc071d5e4 ("tracing/kprobe: Add multi-probe per event support")Signed-off-by Henry Martin <[email protected]>---
v3:
- Steve: wrong fix / wrong file. Move the fix out oftrace_events.cinto the probe layer (traceprobe_define_arg_fields()/trace_probe_event_free()) sotrace_define_field()and static events are untouched. Ownership now lives ontrace_probe_event, whose lifetime matches the event call and its field list.
- Clarify in the changelog that this is kprobe multi-probe-per-event (append_trace_kprobe), not eprobes, and add a shell reproducer.
v2:
- Reworded the module-rodata note (dropped, superseded by v3).kernel/trace/trace_probe.c | 36 +++++++++++++++++++++++++++++++++++- kernel/trace/trace_probe.h | 2 ++ 2 files changed, 37 insertions(+), 1 deletion(-)kernel/trace/trace_probe.c +0
-0@@ -2552,19 +2552,48 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype int traceprobe_define_arg_fields(struct trace_event_call *event_call,
kernel/trace/trace_probe.c int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype · line 2562
Quoted 10 lines
kernel/trace/trace_probe.c +6
-0size_t offset, struct trace_probe *tp) { + struct trace_probe_event *tpe = trace_probe_event_from_call(event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For a +* multi-probe event the field list is defined once by the first probe
Nit. I find "multi-probe event" somewhat ambiguous. Could you reword that to "an event with multiple probes attached," ?
kernel/trace/trace_probe.c int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype · line 2565
Quoted 3 lines
kernel/trace/trace_probe.c +3
-0+* but kept alive by the surviving siblings, so removing that first +* probe would leave the fields referencing freed memory. Make the +* event own duplicates that live as long as the event call itself.
The last sentence doesn't parse for me. Can you reword it?
Other than that, the rest looks good.
Masami, have any thoughts?
-- Steve
Quoted 60 lines
kernel/trace/trace_probe.c +26
-1+*/ +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret =trace_define_field (event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ; + } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER );@@ -2576,6 +2605,11 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,static void trace_probe_event_free (struct trace_probe_event *tpe) { +int i; + +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings);kfree (tpe->class.system);kfree (tpe->call.name);kfree (tpe->call.print_fmt);kernel/trace/trace_probe.h +2
-0@@ -264,6 +264,8 @@ struct trace_probe_event {struct trace_event_call call;struct list_head files;struct list_head probes; +char **field_strings; +int nr_field_strings;struct trace_uprobe_filter filter[]; };
A message that is not in the archive (sent off-list or not yet received): CAEnQdOo0qHQK5veJp0Ybf3Hm3Gn2iUicL9Xj_bTNZKhoMfFOTw@mail.gmail.com
Steven Rostedt
maintainerQuoted 16 lines · On Tue, 25 Aug 2026 19:03:03 +0800 henry martin <[email protected]>…
Quoted 7 lines
Quoted 4 lines
When several probes are appended to the same event, they share the
trace_event_calland its field list, which stays the one defined by the primary probe. Deleting just the primary probe withWhat do you mean by "appended to the same event"? Do you mean eprobes?
Not eprobes -- I mean the kprobe multi-probe-per-event feature from the
Fixes: commit (append_trace_kprobe()): two probes registered under one event name with identical arg names/types but different symbols, so they share a singletrace_event_call. eprobe/uprobe/fprobe are affected too only because they all define their fields through the same helper (traceprobe_define_arg_fields()), but the reproducer below is plain kprobe.
Quoted 3 lines
Quoted 1 line
Can you post a reproducer for this?
Run as root with KASAN, inside the guest:
Does it matter being inside a guest?
Quoted 19 lines
cd
/sys/kernel/tracing# primary A: fields are defined from A's args echo 'p:kprobes/ev vfs_read a1=$arg1' > kprobe_events # append B: shares A's event call echo 'p:kprobes/ev vfs_write a1=$arg1' >> kprobe_events # delete ONLY A (matched by symbol), B survives echo '-:kprobes/ev vfs_read' >> kprobe_events # field lookup -> strcmp() on the freed name echo 'a1 == 1' > events/kprobes/ev/filterBUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 trace_find_event_field parse_pred process_preds create_filter apply_event_filter event_filter_write
Quoted 2 lines
Freed by:
traceprobe_free_probe_arg/trace_probe_cleanup/
free_trace_kprobe/ ... /dyn_event_release
The above is useful information to include in the change log.
Quoted 64 lines
Deleting A runs
trace_probe_cleanup(A), which frees A's args, thentrace_probe_unlink(A)keeps thetrace_probe_eventbecause B is still on the probe list. The event survives via B while its fields still point at A's freedarg->name(and, for array args,arg->fmt). Both the delete and the filter write holdevent_mutex, so it is a dangling reference after removal, not a race -- it triggers every time.Quoted 16 lines
Quoted 16 lines
"-:group/event symbol" frees the
trace_probeand its argument strings, while the event call is kept registered by the remaining sibling probes.field->nameandfield->typeare left dangling, and any field lookup - e.g. writing to events/<grp>/<ev>/filter - reads freed memory:BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call trace: trace_find_event_field+0xd6/0x220 parse_pred process_preds create_filter apply_event_filter event_filter_writeQuoted 14 lines
Quoted 6 lines
Make the field own its strings: duplicate name and type with
kstrdup_const()in__trace_define_field()and release them withkfree_const()intrace_destroy_fields(). Fields of static trace events still reference their kernel/module rodata string literals directly, as kstrdup_const()/kfree_const() only touch memory that was actually allocated.Wrong fix.
Quoted 5 lines
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
Fixes ca89bc071d5e4 ("tracing/kprobe: Add multi-probe per eventsupport")
Quoted 5 lines
Quoted 5 lines
Signed-off-by Henry Martin <[email protected]>--- kernel/trace/trace_events.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)Quoted 8 lines
kernel/trace/trace_events.c
Quoted 4 lines
kernel/trace/trace_events.c +0
-0This is a bug with
trace_probes.cand nottrace_events.c. This should be fixed without touchingtrace_events.c. That is, thetrace_probes.ccode(or
Quoted 2 lines
trace_eprobes.cif it's only affects eprobes) should handle this issue.Agreed, that was the wrong place. v3 keeps
trace_define_field()and all static events untouched and fixes it where the borrowing happens:traceprobe_define_arg_fields()now kstrdup()s the name/type, and the copies are owned by thetrace_probe_event(which embeds the event call and outlives every individual probe), freed intrace_probe_event_free(). It is one helper plus its teardown, both intrace_probe.c, plus two fields on structtrace_probe_event.
Quoted 1 line
v3 is posted as a reply in this thread, tested with KASAN +
Please post new versions as a separate thread. It helps with tooling.
Quoted 9 lines
kasan_multi_shot. The reproducer above triggers the UAF reliably on the unpatched tree; with the patch, deleting the primary probe leaves format/filter intact on the surviving event and the report is gone. I also checked the array-arg
case (arr=+0($arg1):u64[2]), wherefield->typeborrows the kmalloc'dparg->fmt: the type string survives the primary delete and full teardown afterwards shows no double-free.Thanks for the review.
I'll look at your other patch.
Thanks,
-- Steve