mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
Kernel: Use Process::require_no_promises instead of REQUIRE_NO_PROMISES
This change lays the foundation for making the require_promise return an error hand handling the process abort outside of the syscall implementations, to avoid cases where we would leak resources. It also has the advantage that it makes removes a gs pointer read to look up the current thread, then process for every syscall. We can instead go through the Process this pointer in most cases.
This commit is contained in:
parent
bad6d50b86
commit
0f7fe1eb08
Notes:
sideshowbarker
2024-07-17 21:58:36 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/0f7fe1eb088 Pull-request: https://github.com/SerenityOS/serenity/pull/11476
4 changed files with 8 additions and 7 deletions
|
@ -25,7 +25,8 @@ ErrorOr<FlatPtr> Process::sys$gethostname(Userspace<char*> buffer, size_t size)
|
||||||
ErrorOr<FlatPtr> Process::sys$sethostname(Userspace<const char*> buffer, size_t length)
|
ErrorOr<FlatPtr> Process::sys$sethostname(Userspace<const char*> buffer, size_t length)
|
||||||
{
|
{
|
||||||
VERIFY_NO_PROCESS_BIG_LOCK(this)
|
VERIFY_NO_PROCESS_BIG_LOCK(this)
|
||||||
REQUIRE_NO_PROMISES;
|
require_no_promises();
|
||||||
|
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
return EPERM;
|
return EPERM;
|
||||||
if (length > 64)
|
if (length > 64)
|
||||||
|
|
|
@ -21,10 +21,10 @@ namespace Kernel {
|
||||||
ErrorOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*> user_params)
|
ErrorOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*> user_params)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||||
|
require_no_promises();
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
return EPERM;
|
return EPERM;
|
||||||
|
|
||||||
REQUIRE_NO_PROMISES;
|
|
||||||
auto params = TRY(copy_typed_from_user(user_params));
|
auto params = TRY(copy_typed_from_user(user_params));
|
||||||
|
|
||||||
auto source_fd = params.source_fd;
|
auto source_fd = params.source_fd;
|
||||||
|
@ -120,7 +120,7 @@ ErrorOr<FlatPtr> Process::sys$umount(Userspace<const char*> user_mountpoint, siz
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
return EPERM;
|
return EPERM;
|
||||||
|
|
||||||
REQUIRE_NO_PROMISES;
|
require_no_promises();
|
||||||
|
|
||||||
auto mountpoint = TRY(get_syscall_path_argument(user_mountpoint, mountpoint_length));
|
auto mountpoint = TRY(get_syscall_path_argument(user_mountpoint, mountpoint_length));
|
||||||
auto custody = TRY(VirtualFileSystem::the().resolve_path(mountpoint->view(), current_directory()));
|
auto custody = TRY(VirtualFileSystem::the().resolve_path(mountpoint->view(), current_directory()));
|
||||||
|
|
|
@ -19,7 +19,7 @@ u64 g_profiling_event_mask;
|
||||||
ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, u64 event_mask)
|
ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, u64 event_mask)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||||
REQUIRE_NO_PROMISES;
|
require_no_promises();
|
||||||
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
|
@ -69,7 +69,7 @@ ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, u64 event_mask)
|
||||||
ErrorOr<FlatPtr> Process::sys$profiling_disable(pid_t pid)
|
ErrorOr<FlatPtr> Process::sys$profiling_disable(pid_t pid)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||||
REQUIRE_NO_PROMISES;
|
require_no_promises();
|
||||||
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
|
@ -99,7 +99,7 @@ ErrorOr<FlatPtr> Process::sys$profiling_disable(pid_t pid)
|
||||||
ErrorOr<FlatPtr> Process::sys$profiling_free_buffer(pid_t pid)
|
ErrorOr<FlatPtr> Process::sys$profiling_free_buffer(pid_t pid)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||||
REQUIRE_NO_PROMISES;
|
require_no_promises();
|
||||||
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
||||||
ErrorOr<FlatPtr> Process::sys$purge(int mode)
|
ErrorOr<FlatPtr> Process::sys$purge(int mode)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||||
REQUIRE_NO_PROMISES;
|
require_no_promises();
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
return EPERM;
|
return EPERM;
|
||||||
size_t purged_page_count = 0;
|
size_t purged_page_count = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue