Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] tracing: add ref_trace_final_put tracing
@ 2026-07-05  0:36 Eugene Mavick
  2026-07-05  0:36 ` [PATCH 1/4] tracing: add ref_trace_final_put tracepoint Eugene Mavick
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Eugene Mavick @ 2026-07-05  0:36 UTC (permalink / raw)
  To: Will Deacon, Peter Zijlstra, Boqun Feng, Mark Rutland, Gary Guo,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Andrew Morton, Dennis Zhou, Tejun Heo, Christoph Lameter
  Cc: linux-kernel, linux-trace-kernel, linux-mm, Eugene Mavick

When debugging use-after-free(UAF) bugs, knowing when the object reaches
0 references and enters final release can significantly aide the
debugging process.

There is currently no universal way to trace this information.

This patches traces the final puts in the most widely used refcounting
implementations, refcount_t(and thus kref which uses it), and
percpu-ref.

The tracepoint records three fields:
- caller: function that called the refcounting
  function(refcount_sub_and_test, percpu_ref_put_many)
- fn: refcounting function(eg refcount_sub_and_test)
- obj: refcount object(struct percpu_ref, refcount_t) 

Signed-off-by: Eugene Mavick <m@mavick.dev>
---
Eugene Mavick (4):
      tracing: add ref_trace_final_put tracepoint
      refcount: add ref_trace_final_put tracepoint
      percpu-refcount: add ref_trace_final_put trace
      kunit: add test for ref_trace_final_put

 MAINTAINERS                      |   3 +
 include/linux/percpu-refcount.h  |   5 +-
 include/linux/ref_trace.h        |  26 ++++++++
 include/linux/refcount.h         |   2 +
 include/trace/events/ref_trace.h |  46 +++++++++++++
 lib/Kconfig                      |  10 +++
 lib/Makefile                     |   2 +
 lib/ref_trace.c                  |  12 ++++
 lib/tests/Makefile               |   1 +
 lib/tests/ref_trace_kunit.c      | 138 +++++++++++++++++++++++++++++++++++++++
 10 files changed, 244 insertions(+), 1 deletion(-)
---
base-commit: df685633c3dbc67441cc86f1c3fee58de4652ba2
change-id: 20260624-refcount-final-put-trace-49bd7c39bd5a

Best regards,
-- 
Eugene Mavick <m@mavick.dev>



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH 0/4] tracing: add ref_trace_final_put tracing
@ 2026-07-05  1:20 Eugene Mavick via B4 Relay
  2026-07-05  1:20 ` [PATCH 2/4] refcount: add ref_trace_final_put tracepoint Eugene Mavick via B4 Relay
  0 siblings, 1 reply; 9+ messages in thread
From: Eugene Mavick via B4 Relay @ 2026-07-05  1:20 UTC (permalink / raw)
  To: Will Deacon, Peter Zijlstra, Boqun Feng, Mark Rutland, Gary Guo,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Andrew Morton, Dennis Zhou, Tejun Heo, Christoph Lameter
  Cc: linux-kernel, linux-trace-kernel, linux-mm, Eugene Mavick

When debugging use-after-free(UAF) bugs, knowing when the object reaches
0 references and enters final release can significantly aide the
debugging process.

There is currently no universal way to trace this information.

This patches traces the final puts in the most widely used refcounting
implementations, refcount_t(and thus kref which uses it), and
percpu-ref.

The tracepoint records three fields:
- caller: function that called the refcounting
  function(refcount_sub_and_test, percpu_ref_put_many)
- fn: refcounting function(eg refcount_sub_and_test)
- obj: refcount object(struct percpu_ref, refcount_t) 

Signed-off-by: Eugene Mavick <m@mavick.dev>
---
Eugene Mavick (4):
      tracing: add ref_trace_final_put tracepoint
      refcount: add ref_trace_final_put tracepoint
      percpu-refcount: add ref_trace_final_put trace
      kunit: add test for ref_trace_final_put

 MAINTAINERS                      |   3 +
 include/linux/percpu-refcount.h  |   5 +-
 include/linux/ref_trace.h        |  26 ++++++++
 include/linux/refcount.h         |   2 +
 include/trace/events/ref_trace.h |  46 +++++++++++++
 lib/Kconfig                      |  10 +++
 lib/Makefile                     |   2 +
 lib/ref_trace.c                  |  12 ++++
 lib/tests/Makefile               |   1 +
 lib/tests/ref_trace_kunit.c      | 138 +++++++++++++++++++++++++++++++++++++++
 10 files changed, 244 insertions(+), 1 deletion(-)
---
base-commit: df685633c3dbc67441cc86f1c3fee58de4652ba2
change-id: 20260624-refcount-final-put-trace-49bd7c39bd5a

Best regards,
-- 
Eugene Mavick <m@mavick.dev>




^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH 0/4] tracing: add ref_trace_final_put tracing
@ 2026-07-04 23:19 Eugene Mavick
  2026-07-04 23:19 ` [PATCH 2/4] refcount: add ref_trace_final_put tracepoint Eugene Mavick
  0 siblings, 1 reply; 9+ messages in thread
From: Eugene Mavick @ 2026-07-04 23:19 UTC (permalink / raw)
  To: Will Deacon, Peter Zijlstra, Boqun Feng, Mark Rutland, Gary Guo,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Andrew Morton, Dennis Zhou, Tejun Heo, Christoph Lameter
  Cc: linux-kernel, linux-trace-kernel, linux-mm, Eugene Mavick

When debugging use-after-free(UAF) bugs, knowing when the object reaches
0 references and enters final release can significantly aide the
debugging process.

There is currently no universal way to trace this information.

This patches traces the final puts in the most widely used refcounting
implementations, refcount_t(and thus kref which uses it), and
percpu-ref.

The tracepoint records three fields:
- caller: function that called the refcounting
  function(refcount_sub_and_test, percpu_ref_put_many)
- fn: refcounting function(eg refcount_sub_and_test)
- obj: refcount object(struct percpu_ref, refcount_t) 

Signed-off-by: Eugene Mavick <m@mavick.dev>
---
Eugene Mavick (4):
      tracing: add ref_trace_final_put tracepoint
      refcount: add ref_trace_final_put tracepoint
      percpu-refcount: add ref_trace_final_put trace
      kunit: add test for ref_trace_final_put

 MAINTAINERS                      |   3 +
 include/linux/percpu-refcount.h  |   5 +-
 include/linux/ref_trace.h        |  26 ++++++++
 include/linux/refcount.h         |   2 +
 include/trace/events/ref_trace.h |  46 +++++++++++++
 lib/Kconfig                      |  10 +++
 lib/Makefile                     |   2 +
 lib/ref_trace.c                  |  12 ++++
 lib/tests/Makefile               |   1 +
 lib/tests/ref_trace_kunit.c      | 138 +++++++++++++++++++++++++++++++++++++++
 10 files changed, 244 insertions(+), 1 deletion(-)
---
base-commit: df685633c3dbc67441cc86f1c3fee58de4652ba2
change-id: 20260624-refcount-final-put-trace-49bd7c39bd5a

Best regards,
-- 
Eugene Mavick <m@mavick.dev>



^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <20260704-refcount-final-put-trace-v1-0-b48746da1f27@mavick.dev>]

end of thread, other threads:[~2026-07-06 10:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-05  0:36 [PATCH 0/4] tracing: add ref_trace_final_put tracing Eugene Mavick
2026-07-05  0:36 ` [PATCH 1/4] tracing: add ref_trace_final_put tracepoint Eugene Mavick
2026-07-05  0:36 ` [PATCH 2/4] refcount: " Eugene Mavick
2026-07-05  0:36 ` [PATCH 3/4] percpu-refcount: add ref_trace_final_put trace Eugene Mavick
2026-07-05  0:36 ` [PATCH 4/4] kunit: add test for ref_trace_final_put Eugene Mavick
  -- strict thread matches above, loose matches on Subject: below --
2026-07-05  1:20 [PATCH 0/4] tracing: add ref_trace_final_put tracing Eugene Mavick via B4 Relay
2026-07-05  1:20 ` [PATCH 2/4] refcount: add ref_trace_final_put tracepoint Eugene Mavick via B4 Relay
2026-07-06 10:07   ` Usama Arif
2026-07-04 23:19 [PATCH 0/4] tracing: add ref_trace_final_put tracing Eugene Mavick
2026-07-04 23:19 ` [PATCH 2/4] refcount: add ref_trace_final_put tracepoint Eugene Mavick
     [not found] <20260704-refcount-final-put-trace-v1-0-b48746da1f27@mavick.dev>
2026-07-04 11:34 ` Eugene Mavick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox