Commit d3efb98
committed
perf: Disallow mis-matched inherited group reads
jira VULN-6760
cve CVE-2023-5717
commit-author Peter Zijlstra <[email protected]>
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.
Also, add an upstream patch 28a6c6e ("perf/core: Fix potential NULL deref")
which fixes a NULL pointer deref issue in the existing CVE fix.
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 <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
(cherry picked from commit 32671e3)
Signed-off-by: Shreeya Patel <[email protected]>1 parent e656ea9 commit d3efb98
2 files changed
+36
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
803 | 804 | | |
804 | 805 | | |
805 | 806 | | |
| 807 | + | |
| 808 | + | |
806 | 809 | | |
807 | 810 | | |
808 | 811 | | |
| |||
| 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