1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

Kernel/VFS: Ensure working with mount entry per a custody is safe

Previously we could get a raw pointer to a Mount object which might be
invalid when actually dereferencing it.
To ensure this could not happen, we should just use a callback that will
be used immediately after finding the appropriate Mount entry, while
holding the mount table lock.
This commit is contained in:
Liav A 2023-08-04 22:57:25 +03:00 committed by Jelle Raaijmakers
parent d216f780a4
commit 5efb91ec06
2 changed files with 18 additions and 16 deletions

View file

@ -114,8 +114,7 @@ private:
static bool check_matching_absolute_path_hierarchy(Custody const& first_custody, Custody const& second_custody);
bool mount_point_exists_at_custody(Custody& mount_point);
// FIXME: This function is totally unsafe as someone could unmount the returned Mount underneath us.
Mount* find_mount_for_host_custody(Custody const& current_custody);
ErrorOr<void> apply_to_mount_for_host_custody(Custody const& current_custody, Function<void(Mount&)>);
RefPtr<Inode> m_root_inode;