Skip to content

Commit

Permalink
Userland/init: Change file permissions for /dev/(u)random device node
Browse files Browse the repository at this point in the history
We restrict write access to /dev/(u)random.
So only root can feed the kernel entropy pool.

This is a common practice for hardening.
  • Loading branch information
logkos committed Sep 14, 2024
1 parent 247053a commit 6eb7c25
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Userland/Utilities/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static ErrorOr<void> prepare_bare_minimum_devtmpfs_directory_structure()
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/mem"sv, 0600, 1, 1));
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/null"sv, 0666, 1, 3));
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/full"sv, 0666, 1, 7));
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/random"sv, 0666, 1, 8));
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/random"sv, 0644, 1, 8));
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/console"sv, 0666, 5, 1));
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/ptmx"sv, 0666, 5, 2));
TRY(populate_device_node_with_symlink(DeviceNodeType::Character, "/dev/tty"sv, 0666, 5, 0));
Expand All @@ -134,7 +134,7 @@ static ErrorOr<void> prepare_bare_minimum_devtmpfs_directory_structure()
#endif
umask(old_mask);
TRY(Core::System::symlink("/dev/random"sv, "/dev/urandom"sv));
TRY(Core::System::chmod("/dev/urandom"sv, 0666));
TRY(Core::System::chmod("/dev/urandom"sv, 0644));
return {};
}

Expand Down

0 comments on commit 6eb7c25

Please sign in to comment.