mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:37:34 +00:00
Kernel/VFS: Validate paths against process veil in mkdir()
VirtualFileSystem::mkdir() relies on resolve_path() returning an error, since it is only interested in the out_parent passed as a pointer. Since resolve_path_without_veil returns an error, no process veil validation is done by resolve_path() in that case. Due to this problem, mkdir() should use resolve_path_without_veil() and then manually validate if the parent directory of the to-be-created directory is unveiled with 'c' permissions. This fixes a bug where the mkdir syscall would not respect the process veil at all.
This commit is contained in:
parent
8c7010f282
commit
e8f491b01d
1 changed files with 2 additions and 1 deletions
|
@ -363,7 +363,7 @@ ErrorOr<void> VirtualFileSystem::mkdir(StringView path, mode_t mode, Custody& ba
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Custody> parent_custody;
|
RefPtr<Custody> parent_custody;
|
||||||
auto result = resolve_path(path, base, &parent_custody);
|
auto result = resolve_path_without_veil(path, base, &parent_custody);
|
||||||
if (!result.is_error())
|
if (!result.is_error())
|
||||||
return EEXIST;
|
return EEXIST;
|
||||||
else if (!parent_custody)
|
else if (!parent_custody)
|
||||||
|
@ -371,6 +371,7 @@ ErrorOr<void> VirtualFileSystem::mkdir(StringView path, mode_t mode, Custody& ba
|
||||||
// NOTE: If resolve_path fails with a non-null parent custody, the error should be ENOENT.
|
// NOTE: If resolve_path fails with a non-null parent custody, the error should be ENOENT.
|
||||||
VERIFY(result.error().code() == ENOENT);
|
VERIFY(result.error().code() == ENOENT);
|
||||||
|
|
||||||
|
TRY(validate_path_against_process_veil(*parent_custody, O_CREAT));
|
||||||
auto& parent_inode = parent_custody->inode();
|
auto& parent_inode = parent_custody->inode();
|
||||||
auto& current_process = Process::current();
|
auto& current_process = Process::current();
|
||||||
if (!parent_inode.metadata().may_write(current_process))
|
if (!parent_inode.metadata().may_write(current_process))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue