Skip to content

Commit

Permalink
Kernel/VFS: Clear out_parent if path is veiled
Browse files Browse the repository at this point in the history
Previously, VirtualFileSystem::resolve_path() could return a non-null
RefPtr<Custody>* out_parent even if the function errored because the
path has been veiled.

If code relies on recieving the parent custody even if the path is
veiled, it should just call resolve_path_without_veil and do the veil
validation manually. This is because it could be that the parent is
unveiled but the child isn't or the other way round.
  • Loading branch information
MaxWipfli authored and IdanHo committed Feb 13, 2022
1 parent 3ebb3d9 commit 8c7010f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Kernel/FileSystem/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,11 @@ ErrorOr<void> VirtualFileSystem::validate_path_against_process_veil(StringView p
ErrorOr<NonnullRefPtr<Custody>> VirtualFileSystem::resolve_path(StringView path, Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level)
{
auto custody = TRY(resolve_path_without_veil(path, base, out_parent, options, symlink_recursion_level));
TRY(validate_path_against_process_veil(*custody, options));
if (auto result = validate_path_against_process_veil(*custody, options); result.is_error()) {
if (out_parent)
out_parent->clear();
return result.release_error();
}
return custody;
}

Expand Down

0 comments on commit 8c7010f

Please sign in to comment.