This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
[LibOS] Do not reuse dentries after removing a file (fixes mknod crash) #2499
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Found while investigating #2419.
Description of the changes
This change ensures that dentries for removed files are not reused. Instead of marking a dentry as negative, we mark it as invalid, and make sure that a new one is created during next lookup.
This fixes a crash where we create a named pipe, remove it, and then reuse the same object for a normal file. More generally, it ensures that filesystems always receive a dentry in a consistent state.
Several unused dentry flags are also removed.
How to test this PR?
mkfifo
that crashes in same manner on master.dump_dcache(NULL);
toshim_exit.c
, and ran a few sanity checks withgraphene-direct python -c "<script>"
:import os; open('x', 'w').close(); os.unlink('x')
(should show an invalid dentry)...; os.path.exists('x')
(should show a new, negative dentry, with no mode etc. set)...; os.readdir(".")
(should show no dentry, due to lookup triggeringdentry_gc()
)This change is