perf: Disallow mis-matched inherited group reads
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 fa8c2693 ("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: fa8c2693 ("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
parent
58720809
-
mentioned in commit 555e15e9
-
mentioned in commit a714491f
-
mentioned in commit 487a8e24
-
mentioned in commit 71d224ac
-
mentioned in commit 7252c8b9
-
mentioned in commit f6952655
-
mentioned in commit 20f925d3
-
mentioned in commit a71ef314
-
mentioned in commit 8b8cde8e
-
mentioned in commit 51617780
-
mentioned in commit ce7c6ad1
-
mentioned in commit c9e02711
-
mentioned in commit 0258ca32
-
mentioned in commit 21b07a2e
-
mentioned in commit 511f3e9b
Please register or sign in to comment