linux-stable/include
Peter Zijlstra a714491fa9 perf: Disallow mis-matched inherited group reads
commit 32671e3799 upstream.

Because group consistency is non-atomic between parent (filedesc) and children
(inherited) events, it is possible for PERF_FORMAT_GROUP read() to try and sum
non-matching counter groups -- with non-sensical results.

Add group_generation to distinguish the case where a parent group removes and
adds an event and thus has the same number, but a different configuration of
events as inherited groups.

This became a problem when commit fa8c269353 ("perf/core: Invert
perf_read_group() loops") flipped the order of child_list and sibling_list.
Previously it would iterate the group (sibling_list) first, and for each
sibling traverse the child_list. In this order, only the group composition of
the parent is relevant. By flipping the order the group composition of the
child (inherited) events becomes an issue and the mis-match in group
composition becomes evident.

That said; even prior to this commit, while reading of a group that is not
equally inherited was not broken, it still made no sense.

(Ab)use ECHILD as error return to indicate issues with child process group
composition.

Fixes: fa8c269353 ("perf/core: Invert perf_read_group() loops")
Reported-by: Budimir Markovic <markovicbudimir@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20231018115654.GK33217@noisy.programming.kicks-ass.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-25 11:17:02 +02:00
..
acpi ACPI: CPPC: Do not prevent CPPC from working in the future 2022-08-25 11:15:30 +02:00
asm-generic word-at-a-time: use the same return type for has_zero regardless of endianness 2023-08-11 11:45:36 +02:00
clocksource
crypto crypto: drbg - make reseeding from get_random_bytes() synchronous 2022-06-25 11:49:13 +02:00
drm drm/mipi-dsi: Fix byte order of 16-bit DCS set/get brightness 2023-03-11 16:31:40 +01:00
dt-bindings
keys
kvm
linux perf: Disallow mis-matched inherited group reads 2023-10-25 11:17:02 +02:00
math-emu
media media: v4l2-mem2mem: add lock to protect parameter num_rdy 2023-08-30 16:31:43 +02:00
memory
misc
net Bluetooth: hci_core: Fix build warnings 2023-10-25 11:16:56 +02:00
pcmcia
ras
rdma RDMA/netlink: Add __maybe_unused to static inline in C file 2021-11-26 11:36:24 +01:00
scsi scsi: core: Use 32-bit hostnum in scsi_host_lookup() 2023-09-23 10:48:08 +02:00
soc
sound ALSA: core: Add async signal helpers 2022-08-25 11:15:46 +02:00
target scsi: target: Fix ordered tag handling 2021-11-26 11:36:20 +01:00
trace nohz: Add TICK_DEP_BIT_RCU 2023-05-17 11:13:22 +02:00
uapi bpf: Clarify error expectations from bpf_clone_redirect 2023-10-10 21:44:58 +02:00
video video: of_display_timing.h: include errno.h 2022-07-12 16:29:01 +02:00
xen xen/gnttab: fix gnttab_end_foreign_access() without page specified 2022-03-11 10:15:13 +01:00