mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
Kernel: Tighten up some promise checks
Since we're not keeping compatibility with OpenBSD about what promises are required for which syscalls, tighten things up so that they make more sense.
This commit is contained in:
parent
a77405665f
commit
05b7fec517
Notes:
sideshowbarker
2024-07-19 05:55:22 +09:00
Author: https://github.com/bugaevc
Commit: 05b7fec517
Pull-request: https://github.com/SerenityOS/serenity/pull/2468
2 changed files with 5 additions and 10 deletions
|
@ -703,7 +703,7 @@ int Process::sys$gethostname(char* buffer, ssize_t size)
|
||||||
|
|
||||||
int Process::sys$sethostname(const char* hostname, ssize_t length)
|
int Process::sys$sethostname(const char* hostname, ssize_t length)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_NO_PROMISES;
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
|
@ -2495,7 +2495,7 @@ KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
|
||||||
|
|
||||||
pid_t Process::sys$waitid(const Syscall::SC_waitid_params* user_params)
|
pid_t Process::sys$waitid(const Syscall::SC_waitid_params* user_params)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(proc);
|
||||||
|
|
||||||
Syscall::SC_waitid_params params;
|
Syscall::SC_waitid_params params;
|
||||||
if (!validate_read_and_copy_typed(¶ms, user_params))
|
if (!validate_read_and_copy_typed(¶ms, user_params))
|
||||||
|
@ -2545,7 +2545,7 @@ bool Process::validate_write(void* address, size_t size) const
|
||||||
|
|
||||||
pid_t Process::sys$getsid(pid_t pid)
|
pid_t Process::sys$getsid(pid_t pid)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(proc);
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
return m_sid;
|
return m_sid;
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
|
@ -2576,7 +2576,7 @@ pid_t Process::sys$setsid()
|
||||||
|
|
||||||
pid_t Process::sys$getpgid(pid_t pid)
|
pid_t Process::sys$getpgid(pid_t pid)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(proc);
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
return m_pgid;
|
return m_pgid;
|
||||||
InterruptDisabler disabler; // FIXME: Use a ProcessHandle
|
InterruptDisabler disabler; // FIXME: Use a ProcessHandle
|
||||||
|
@ -2677,7 +2677,7 @@ int Process::sys$dup2(int old_fd, int new_fd)
|
||||||
|
|
||||||
int Process::sys$sigprocmask(int how, const sigset_t* set, sigset_t* old_set)
|
int Process::sys$sigprocmask(int how, const sigset_t* set, sigset_t* old_set)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(sigaction);
|
||||||
if (old_set) {
|
if (old_set) {
|
||||||
if (!validate_write_typed(old_set))
|
if (!validate_write_typed(old_set))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
|
@ -31,11 +31,6 @@
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio", nullptr) < 0) {
|
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
char buffer[HOST_NAME_MAX];
|
char buffer[HOST_NAME_MAX];
|
||||||
int rc = gethostname(buffer, sizeof(buffer));
|
int rc = gethostname(buffer, sizeof(buffer));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue