Commit a06247c
psi: Fix uaf issue when psi trigger is destroyed while being polled
With write operation on psi files replacing old trigger with a new one,
the lifetime of its waitqueue is totally arbitrary. Overwriting an
existing trigger causes its waitqueue to be freed and pending poll()
will stumble on trigger->event_wait which was destroyed.
Fix this by disallowing to redefine an existing psi trigger. If a write
operation is used on a file descriptor with an already existing psi
trigger, the operation will fail with EBUSY error.
Also bypass a check for psi_disabled in the psi_trigger_destroy as the
flag can be flipped after the trigger is created, leading to a memory
leak.
Fixes: 0e94682 ("psi: introduce psi monitor")
Reported-by: syzbot+cdb5dd11c97cc532efad@syzkaller.appspotmail.com
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Analyzed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220111232309.1786347-1-surenb@google.com1 parent fb3b067 commit a06247c
File tree
5 files changed
+40
-45
lines changed- Documentation/accounting
- include/linux
- kernel
- cgroup
- sched
5 files changed
+40
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | 144 | | |
148 | 145 | | |
149 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3643 | 3643 | | |
3644 | 3644 | | |
3645 | 3645 | | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
3646 | 3652 | | |
3647 | 3653 | | |
3648 | 3654 | | |
3649 | 3655 | | |
3650 | 3656 | | |
3651 | 3657 | | |
3652 | 3658 | | |
3653 | | - | |
3654 | | - | |
| 3659 | + | |
3655 | 3660 | | |
3656 | 3661 | | |
3657 | 3662 | | |
| |||
3690 | 3695 | | |
3691 | 3696 | | |
3692 | 3697 | | |
3693 | | - | |
| 3698 | + | |
3694 | 3699 | | |
3695 | 3700 | | |
3696 | 3701 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1162 | 1162 | | |
1163 | 1163 | | |
1164 | 1164 | | |
1165 | | - | |
1166 | 1165 | | |
1167 | 1166 | | |
1168 | 1167 | | |
| |||
1191 | 1190 | | |
1192 | 1191 | | |
1193 | 1192 | | |
1194 | | - | |
| 1193 | + | |
1195 | 1194 | | |
1196 | | - | |
1197 | | - | |
| 1195 | + | |
1198 | 1196 | | |
1199 | 1197 | | |
1200 | | - | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
1201 | 1203 | | |
1202 | 1204 | | |
| 1205 | + | |
1203 | 1206 | | |
1204 | 1207 | | |
1205 | 1208 | | |
| |||
1235 | 1238 | | |
1236 | 1239 | | |
1237 | 1240 | | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
1241 | 1244 | | |
1242 | 1245 | | |
1243 | 1246 | | |
| |||
1254 | 1257 | | |
1255 | 1258 | | |
1256 | 1259 | | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | | - | |
1269 | 1260 | | |
1270 | 1261 | | |
1271 | 1262 | | |
| |||
1275 | 1266 | | |
1276 | 1267 | | |
1277 | 1268 | | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
| 1269 | + | |
| 1270 | + | |
1283 | 1271 | | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
1288 | 1272 | | |
1289 | 1273 | | |
1290 | 1274 | | |
1291 | 1275 | | |
1292 | 1276 | | |
1293 | 1277 | | |
1294 | | - | |
1295 | | - | |
1296 | 1278 | | |
1297 | 1279 | | |
1298 | 1280 | | |
| |||
1316 | 1298 | | |
1317 | 1299 | | |
1318 | 1300 | | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | 1301 | | |
| 1302 | + | |
1324 | 1303 | | |
1325 | 1304 | | |
1326 | | - | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
1327 | 1319 | | |
1328 | 1320 | | |
1329 | 1321 | | |
| |||
1358 | 1350 | | |
1359 | 1351 | | |
1360 | 1352 | | |
1361 | | - | |
| 1353 | + | |
1362 | 1354 | | |
1363 | 1355 | | |
1364 | 1356 | | |
| |||
0 commit comments