Commit 9e13e56
committed
perf: Disallow mis-matched inherited group reads
jira VULN-8890
cve CVE-2023-5717
commit-author Peter Zijlstra <peterz@infradead.org>
commit 32671e3
upstream-diff This patch causes kABI breakage due to a change in the
struct perf_event layout after adding the group_generation field.
Hence, to preserve kABI compatibility, use RH_KABI_EXTEND macro
to safely append the new field without affecting the existing layout.
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 7ded590 commit 9e13e56
2 files changed
+36
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
811 | 812 | | |
812 | 813 | | |
813 | 814 | | |
| 815 | + | |
| 816 | + | |
814 | 817 | | |
815 | 818 | | |
816 | 819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2022 | 2022 | | |
2023 | 2023 | | |
2024 | 2024 | | |
| 2025 | + | |
2025 | 2026 | | |
2026 | 2027 | | |
2027 | 2028 | | |
| |||
2216 | 2217 | | |
2217 | 2218 | | |
2218 | 2219 | | |
| 2220 | + | |
2219 | 2221 | | |
2220 | 2222 | | |
2221 | 2223 | | |
| |||
5282 | 5284 | | |
5283 | 5285 | | |
5284 | 5286 | | |
5285 | | - | |
| 5287 | + | |
5286 | 5288 | | |
5287 | 5289 | | |
5288 | 5290 | | |
| |||
5292 | 5294 | | |
5293 | 5295 | | |
5294 | 5296 | | |
| 5297 | + | |
| 5298 | + | |
| 5299 | + | |
| 5300 | + | |
| 5301 | + | |
| 5302 | + | |
| 5303 | + | |
| 5304 | + | |
| 5305 | + | |
| 5306 | + | |
| 5307 | + | |
| 5308 | + | |
| 5309 | + | |
| 5310 | + | |
| 5311 | + | |
| 5312 | + | |
| 5313 | + | |
| 5314 | + | |
| 5315 | + | |
| 5316 | + | |
| 5317 | + | |
| 5318 | + | |
| 5319 | + | |
| 5320 | + | |
| 5321 | + | |
| 5322 | + | |
| 5323 | + | |
5295 | 5324 | | |
5296 | 5325 | | |
5297 | 5326 | | |
| |||
5321 | 5350 | | |
5322 | 5351 | | |
5323 | 5352 | | |
| 5353 | + | |
5324 | 5354 | | |
5325 | | - | |
| 5355 | + | |
5326 | 5356 | | |
5327 | 5357 | | |
5328 | 5358 | | |
| |||
5341 | 5371 | | |
5342 | 5372 | | |
5343 | 5373 | | |
5344 | | - | |
5345 | | - | |
5346 | | - | |
5347 | | - | |
5348 | 5374 | | |
5349 | 5375 | | |
5350 | 5376 | | |
| |||
13005 | 13031 | | |
13006 | 13032 | | |
13007 | 13033 | | |
| 13034 | + | |
13008 | 13035 | | |
13009 | 13036 | | |
13010 | 13037 | | |
| |||
0 commit comments