Skip to content

Commit

Permalink
Kernel: Reject create links on paths that were not unveiled as writable
Browse files Browse the repository at this point in the history
This solves one of the security issues being mentioned in issue SerenityOS#15996.
We simply don't allow creating hardlinks on paths that were not unveiled
as writable to prevent possible bypass on a certain path that was
unveiled as non-writable.
  • Loading branch information
supercomputer7 authored and ADKaster committed Dec 3, 2022
1 parent 0eeba70 commit 69f41eb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Kernel/FileSystem/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,9 @@ static bool hard_link_allowed(Credentials const& credentials, Inode const& inode

ErrorOr<void> VirtualFileSystem::link(Credentials const& credentials, StringView old_path, StringView new_path, Custody& base)
{
auto old_custody = TRY(resolve_path(credentials, old_path, base));
// NOTE: To prevent unveil bypass by creating an hardlink after unveiling a path as read-only,
// check that if write permission is allowed by the veil info on the old_path.
auto old_custody = TRY(resolve_path(credentials, old_path, base, nullptr, O_RDWR));
auto& old_inode = old_custody->inode();

RefPtr<Custody> parent_custody;
Expand Down

0 comments on commit 69f41eb

Please sign in to comment.