diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 1357b9fc54..a0f63d6337 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -33,6 +33,15 @@ enum class NeedsBigProcessLock { No }; +// Declare all syscalls and associated metadata. +// +// NOTE: When declaring a new syscall or modifying an existing, please +// ensure that the proper assert is present at the top of the syscall +// implementation to both verify and document to any readers if the +// syscall aquires the big process lock or not. The asserts are: +// - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) +// - VERIFY_NO_PROCESS_BIG_LOCK(this) +// #define ENUMERATE_SYSCALLS(S) \ S(yield, NeedsBigProcessLock::Yes) \ S(open, NeedsBigProcessLock::Yes) \ diff --git a/Kernel/Syscalls/access.cpp b/Kernel/Syscalls/access.cpp index a8dc4c1aa9..267231a6d0 100644 --- a/Kernel/Syscalls/access.cpp +++ b/Kernel/Syscalls/access.cpp @@ -12,6 +12,7 @@ namespace Kernel { KResultOr Process::sys$access(Userspace user_path, size_t path_length, int mode) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(rpath); auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) diff --git a/Kernel/Syscalls/alarm.cpp b/Kernel/Syscalls/alarm.cpp index 1312b78061..1bbc81963b 100644 --- a/Kernel/Syscalls/alarm.cpp +++ b/Kernel/Syscalls/alarm.cpp @@ -11,6 +11,7 @@ namespace Kernel { KResultOr Process::sys$alarm(unsigned seconds) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(stdio); unsigned previous_alarm_remaining = 0; if (m_alarm_timer) { diff --git a/Kernel/Syscalls/anon_create.cpp b/Kernel/Syscalls/anon_create.cpp index 7c95d9e1ac..6a83b9f0d7 100644 --- a/Kernel/Syscalls/anon_create.cpp +++ b/Kernel/Syscalls/anon_create.cpp @@ -13,6 +13,7 @@ namespace Kernel { KResultOr Process::sys$anon_create(size_t size, int options) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(stdio); if (!size) diff --git a/Kernel/Syscalls/beep.cpp b/Kernel/Syscalls/beep.cpp index 337f61fa97..0f0a21a640 100644 --- a/Kernel/Syscalls/beep.cpp +++ b/Kernel/Syscalls/beep.cpp @@ -11,6 +11,7 @@ namespace Kernel { KResultOr Process::sys$beep() { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); PCSpeaker::tone_on(440); auto result = Thread::current()->sleep(Time::from_nanoseconds(200'000'000)); PCSpeaker::tone_off(); diff --git a/Kernel/Syscalls/chdir.cpp b/Kernel/Syscalls/chdir.cpp index 995d098890..f3442b695a 100644 --- a/Kernel/Syscalls/chdir.cpp +++ b/Kernel/Syscalls/chdir.cpp @@ -13,6 +13,7 @@ namespace Kernel { KResultOr Process::sys$chdir(Userspace user_path, size_t path_length) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(rpath); auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) @@ -26,6 +27,7 @@ KResultOr Process::sys$chdir(Userspace user_path, size_t p KResultOr Process::sys$fchdir(int fd) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(stdio); auto description = fds().file_description(fd); if (!description) @@ -43,6 +45,7 @@ KResultOr Process::sys$fchdir(int fd) KResultOr Process::sys$getcwd(Userspace buffer, size_t size) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(rpath); if (size > NumericLimits::max()) diff --git a/Kernel/Syscalls/chmod.cpp b/Kernel/Syscalls/chmod.cpp index 387581b64c..caf55a939a 100644 --- a/Kernel/Syscalls/chmod.cpp +++ b/Kernel/Syscalls/chmod.cpp @@ -13,6 +13,7 @@ namespace Kernel { KResultOr Process::sys$chmod(Userspace user_path, size_t path_length, mode_t mode) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(fattr); auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) @@ -22,6 +23,7 @@ KResultOr Process::sys$chmod(Userspace user_path, size_t p KResultOr Process::sys$fchmod(int fd, mode_t mode) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(fattr); auto description = fds().file_description(fd); if (!description) diff --git a/Kernel/Syscalls/chown.cpp b/Kernel/Syscalls/chown.cpp index 33e155f12f..6e899ec046 100644 --- a/Kernel/Syscalls/chown.cpp +++ b/Kernel/Syscalls/chown.cpp @@ -11,6 +11,7 @@ namespace Kernel { KResultOr Process::sys$fchown(int fd, uid_t uid, gid_t gid) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(chown); auto description = fds().file_description(fd); if (!description) @@ -20,6 +21,7 @@ KResultOr Process::sys$fchown(int fd, uid_t uid, gid_t gid) KResultOr Process::sys$chown(Userspace user_params) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(chown); Syscall::SC_chown_params params; if (!copy_from_user(¶ms, user_params)) diff --git a/Kernel/Syscalls/chroot.cpp b/Kernel/Syscalls/chroot.cpp index 67ca084bdb..5f13bccc91 100644 --- a/Kernel/Syscalls/chroot.cpp +++ b/Kernel/Syscalls/chroot.cpp @@ -13,6 +13,7 @@ namespace Kernel { KResultOr Process::sys$chroot(Userspace user_path, size_t path_length, int mount_flags) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); if (!is_superuser()) return EPERM; REQUIRE_PROMISE(chroot); diff --git a/Kernel/Syscalls/clock.cpp b/Kernel/Syscalls/clock.cpp index ab20e666f0..990447ade2 100644 --- a/Kernel/Syscalls/clock.cpp +++ b/Kernel/Syscalls/clock.cpp @@ -12,6 +12,7 @@ namespace Kernel { KResultOr Process::sys$clock_gettime(clockid_t clock_id, Userspace user_ts) { + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); REQUIRE_PROMISE(stdio); if (!TimeManagement::is_valid_clock_id(clock_id)) @@ -26,6 +27,7 @@ KResultOr Process::sys$clock_gettime(clockid_t clock_id, Userspace