Commit 9e0488d
committed
client: crash caused by invalid iterator in _readdir_cache_cb
Capacity of `readdir_cache` may change after `client_lock` is unlocked in iterations of `readdir_cache`,
and it can cause the iterator to be invalid, then using the invalid iterator in the next iteration will cause crash.
Crash may happen at `Dentry *dn = *pd` (pd points to invalid memory),
or at `if (pd >= dir->readdir_cache.end() || *pd != dn)` (pd is smaller than begin() if idx is negative).
Use index instead of iterator to solve this problem.
Fixes: https://tracker.ceph.com/issues/72247
Signed-off-by: Zhansong Gao <[email protected]>1 parent b352f56 commit 9e0488d
1 file changed
+8
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9461 | 9461 | | |
9462 | 9462 | | |
9463 | 9463 | | |
9464 | | - | |
| 9464 | + | |
| 9465 | + | |
| 9466 | + | |
9465 | 9467 | | |
9466 | 9468 | | |
9467 | 9469 | | |
9468 | | - | |
9469 | | - | |
9470 | | - | |
| 9470 | + | |
9471 | 9471 | | |
9472 | 9472 | | |
9473 | | - | |
9474 | 9473 | | |
9475 | 9474 | | |
9476 | 9475 | | |
9477 | 9476 | | |
9478 | | - | |
9479 | 9477 | | |
9480 | 9478 | | |
9481 | 9479 | | |
9482 | | - | |
9483 | 9480 | | |
9484 | 9481 | | |
9485 | 9482 | | |
| |||
9493 | 9490 | | |
9494 | 9491 | | |
9495 | 9492 | | |
9496 | | - | |
9497 | | - | |
9498 | | - | |
| 9493 | + | |
| 9494 | + | |
9499 | 9495 | | |
9500 | 9496 | | |
9501 | 9497 | | |
| |||
9505 | 9501 | | |
9506 | 9502 | | |
9507 | 9503 | | |
9508 | | - | |
9509 | | - | |
| 9504 | + | |
9510 | 9505 | | |
9511 | 9506 | | |
9512 | 9507 | | |
| |||
9517 | 9512 | | |
9518 | 9513 | | |
9519 | 9514 | | |
| 9515 | + | |
9520 | 9516 | | |
9521 | 9517 | | |
9522 | 9518 | | |
| |||
0 commit comments