linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/15] perf: Convert mmap() related reference counts to refcount_t
@ 2025-08-12 10:38 Peter Zijlstra
  2025-08-12 10:38 ` [PATCH v3 01/15] perf: Remove redundant condition for AUX buffer size Peter Zijlstra
                   ` (15 more replies)
  0 siblings, 16 replies; 54+ messages in thread
From: Peter Zijlstra @ 2025-08-12 10:38 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, peterz, torvalds, mingo, namhyung, acme, kees

Took over the series from Thomas; much thanks to him for cleaning this up.

The recently fixed reference count leaks could have been detected by using
refcount_t and refcount_t would have mitigated the potential overflow at
least.

It turned out that converting the code as is does not work as the
allocation code ends up doing a refcount_inc() for the first allocation,
which causes refcount_t sanity checks to emit a UAF warning.

The reason is that the code is sharing functionality at the wrong level and
ends up being overly complicated for no reason. That's what inevitable led
to the refcount leak problems.

Address this by splitting the ringbuffer and the AUX buffer mapping and
allocation parts out into seperate functions, which handle the reference
counts in a sane way.

That not only simplifies the code and makes it halfways comprehensible, but
also allows to convert the mmap() related reference counts to refcount_t.

It survives lightweight testing with perf and passes the perf/mmap
selftest.

Also available at:

  git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git perf/core

---
v2: https://lkml.kernel.org/r/20250811123458.050061356@linutronix.de

Changes vs v2:
 - replaced patches 4,5 with fine grained steps


^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2025-08-18 10:23 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 10:38 [PATCH v3 00/15] perf: Convert mmap() related reference counts to refcount_t Peter Zijlstra
2025-08-12 10:38 ` [PATCH v3 01/15] perf: Remove redundant condition for AUX buffer size Peter Zijlstra
2025-08-13  5:35   ` Lorenzo Stoakes
2025-08-18 10:23   ` [tip: perf/core] " tip-bot2 for Thomas Gleixner
2025-08-12 10:39 ` [PATCH v3 02/15] perf: Split out mlock limit handling Peter Zijlstra
2025-08-13  5:36   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Thomas Gleixner
2025-08-12 10:39 ` [PATCH v3 03/15] perf: Split out VM accounting Peter Zijlstra
2025-08-13  5:37   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Thomas Gleixner
2025-08-12 10:39 ` [PATCH v3 04/15] perf: Move perf_mmap_calc_limits() into both rb and aux branches Peter Zijlstra
2025-08-13  5:28   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 05/15] perf: Merge consecutive conditionals in perf_mmap() Peter Zijlstra
2025-08-13  5:41   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 06/15] perf: Move common code into both rb and aux branches Peter Zijlstra
2025-08-13  5:55   ` Lorenzo Stoakes
2025-08-13  8:25     ` Peter Zijlstra
2025-08-13  8:27       ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 07/15] perf: Remove redundant aux_unlock label Peter Zijlstra
2025-08-13  5:56   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 08/15] perf: Use guard() for aux_mutex in perf_mmap() Peter Zijlstra
2025-08-13  6:00   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 09/15] perf: Reflow to get rid of aux_success label Peter Zijlstra
2025-08-13  6:03   ` Lorenzo Stoakes
2025-08-13  8:29     ` Peter Zijlstra
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 10/15] perf: Split out the AUX buffer allocation Peter Zijlstra
2025-08-13  6:10   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 11/15] perf: Make RB allocation branch self sufficient Peter Zijlstra
2025-08-13  6:24   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 12/15] perf: Split out the RB allocation Peter Zijlstra
2025-08-13  6:35   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 13/15] perf: Use scoped_guard() for mmap_mutex in perf_mmap() Peter Zijlstra
2025-08-13  6:42   ` Lorenzo Stoakes
2025-08-13  8:32     ` Peter Zijlstra
2025-08-13  8:44       ` Peter Zijlstra
2025-08-13  8:52         ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 14/15] perf: Identify the 0->1 transition for event::mmap_count Peter Zijlstra
2025-08-12 11:15   ` Peter Zijlstra
2025-08-13  6:53     ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-12 10:39 ` [PATCH v3 15/15] perf: Convert mmap() refcounts to refcount_t Peter Zijlstra
2025-08-13  7:09   ` Lorenzo Stoakes
2025-08-18 10:22   ` [tip: perf/core] " tip-bot2 for Thomas Gleixner
2025-08-13  7:11 ` [PATCH v3 00/15] perf: Convert mmap() related reference counts " Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).