Commit 8b7eacd
committed
perf: Disallow mis-matched inherited group reads
jira VULN-6760
pre-cve CVE-2023-5717
commit-author Peter Zijlstra <peterz@infradead.org>
commit 32671e3
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 fa8c269 ("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: fa8c269 ("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
(cherry picked from commit 32671e3)
Signed-off-by: Shreeya Patel <spatel@ciq.com>1 parent e656ea9 commit 8b7eacd
2 files changed
+34
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
| 694 | + | |
694 | 695 | | |
695 | 696 | | |
696 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1956 | 1956 | | |
1957 | 1957 | | |
1958 | 1958 | | |
| 1959 | + | |
1959 | 1960 | | |
1960 | 1961 | | |
1961 | 1962 | | |
| |||
2150 | 2151 | | |
2151 | 2152 | | |
2152 | 2153 | | |
| 2154 | + | |
2153 | 2155 | | |
2154 | 2156 | | |
2155 | 2157 | | |
| |||
5239 | 5241 | | |
5240 | 5242 | | |
5241 | 5243 | | |
5242 | | - | |
| 5244 | + | |
5243 | 5245 | | |
5244 | 5246 | | |
5245 | 5247 | | |
| |||
5249 | 5251 | | |
5250 | 5252 | | |
5251 | 5253 | | |
| 5254 | + | |
| 5255 | + | |
| 5256 | + | |
| 5257 | + | |
| 5258 | + | |
| 5259 | + | |
| 5260 | + | |
| 5261 | + | |
| 5262 | + | |
| 5263 | + | |
| 5264 | + | |
| 5265 | + | |
| 5266 | + | |
| 5267 | + | |
| 5268 | + | |
| 5269 | + | |
| 5270 | + | |
| 5271 | + | |
| 5272 | + | |
| 5273 | + | |
| 5274 | + | |
| 5275 | + | |
| 5276 | + | |
| 5277 | + | |
| 5278 | + | |
| 5279 | + | |
| 5280 | + | |
5252 | 5281 | | |
5253 | 5282 | | |
5254 | 5283 | | |
| |||
5282 | 5311 | | |
5283 | 5312 | | |
5284 | 5313 | | |
| 5314 | + | |
5285 | 5315 | | |
5286 | | - | |
| 5316 | + | |
5287 | 5317 | | |
5288 | 5318 | | |
5289 | 5319 | | |
| |||
5302 | 5332 | | |
5303 | 5333 | | |
5304 | 5334 | | |
5305 | | - | |
5306 | | - | |
5307 | | - | |
5308 | | - | |
5309 | 5335 | | |
5310 | 5336 | | |
5311 | 5337 | | |
| |||
13117 | 13143 | | |
13118 | 13144 | | |
13119 | 13145 | | |
| 13146 | + | |
13120 | 13147 | | |
13121 | 13148 | | |
13122 | 13149 | | |
| |||
0 commit comments