gramine icon indicating copy to clipboard operation
gramine copied to clipboard

[LibOS] Fix dentry of open file handles related to a rename

Open g2flyer opened this issue 1 year ago • 0 comments

During rename, the dentry of the corresponding handle is not updated, which e.g., makes fchown not work properly. I did discover that during work on issue #1835 in Draft PR #1856 where i have to be able to figure out stale handles. A corresponding test-case is added as test_rename_fchown_fchmod in rename_unlink. An additional rename related test case test_rename_follow test the "flip-side" of test_rename_replace (the one which originally triggered me finding the bug).

BTW: the original (in)validation tests from here are moved now to PR #1875. To still have these tests, this PR is currently rebased on the that PRs branch rather than master and currently marked as draft. Will remove the draft once #1875 is merged and i can rebase to master

Description of the changes

To fix that, do_rename iterates over open file handles and fixes any which was was pointing to the source-dentry of the rename.

PS: I'm not very "fluent" on the overall locking strategy. I didn't find anything obvious where my code violates invarients but definitely good to cross-check that (a) using sufficents locks and (b) the implied lock prioties g_dcache.lock > libos_handle_map.lock > libos_handle.lock does not violate anything.

How to test this PR?

I tested by adding the two new test-cases and then running the usual regression tests.


This change is Reviewable

g2flyer avatar May 07 '24 03:05 g2flyer