client: crash caused by invalid iterator in _readdir_cache_cb#64627
client: crash caused by invalid iterator in _readdir_cache_cb#64627
Conversation
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 <zhsgao@hotmail.com>
33c18be to
9e0488d
Compare
|
@dparmar18 PTAL |
|
jenkins retest this please |
|
@dparmar18 ptal to review the fix. |
|
jenkins test windows |
on it now |
|
@dparmar18 gentle nudge on this. |
|
@zhsgao the code looks good, can this be reproduced locally/easily? Do you have/know any instances where it crashed? |
I have a few crashes and I find out through the coredump that they happen at |
yeah if the invalid |
|
This PR is under test in https://tracker.ceph.com/issues/72565. |
I have tried to reproduce the crash but have not been successful, so there is no case for it yet. |
Have to rerun tests due to unrelated infra failures. |
* refs/pull/64627/head:
|
Nice work @zhsgao |
Capacity of
readdir_cachemay change afterclient_lockis unlocked in iterations ofreaddir_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 atif (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 zhsgao@hotmail.com
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job Definition