mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 0/6] perf: Convert mmap() related reference counts to refcount_t
@ 2025-08-06 20:12 Thomas Gleixner
  2025-08-06 20:12 ` [patch 1/6] perf/core: Remove redundant condition for AUX buffer size Thomas Gleixner
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Thomas Gleixner @ 2025-08-06 20:12 UTC (permalink / raw)
  To: LKML
  Cc: Linus Torvalds, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
	Arnaldo Carvalho de Melo, Lorenzo Stoakes, Kees Cook

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.

The series applies on top of Linus tree and is also available from git:

    git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git perf/refcounts

Thanks,

	tglx
---
 include/linux/perf_event.h  |    2 
 kernel/events/core.c        |  361 ++++++++++++++++++++++----------------------
 kernel/events/internal.h    |    4 
 kernel/events/ring_buffer.c |    2 
 4 files changed, 185 insertions(+), 184 deletions(-)

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

end of thread, other threads:[~2025-08-11  6:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-06 20:12 [patch 0/6] perf: Convert mmap() related reference counts to refcount_t Thomas Gleixner
2025-08-06 20:12 ` [patch 1/6] perf/core: Remove redundant condition for AUX buffer size Thomas Gleixner
2025-08-07 13:30   ` Lorenzo Stoakes
2025-08-06 20:12 ` [patch 2/6] perf/core: Split out mlock limit handling Thomas Gleixner
2025-08-07 14:14   ` Lorenzo Stoakes
2025-08-06 20:12 ` [patch 3/6] perf/core: Split out VM accounting Thomas Gleixner
2025-08-07 14:25   ` Lorenzo Stoakes
2025-08-06 20:12 ` [patch 4/6] perf/core: Split out ringbuffer allocation Thomas Gleixner
2025-08-07 15:38   ` Lorenzo Stoakes
2025-08-11  6:26     ` Thomas Gleixner
2025-08-06 20:13 ` [patch 5/6] perf/core: Split the ringbuffer mmap() and allocation code out Thomas Gleixner
2025-08-06 20:13 ` [patch 6/6] perf/core: Convert mmap() refcounts to refcount_t Thomas Gleixner
2025-08-07 15:39 ` [patch 0/6] 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

all inboxes | Powered by JetHome®