1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

Kernel: Support pledge() with empty promises

This tells the kernel that the process wants to use pledge, but without
pledging anything - effectively restricting it to syscalls that don't
require a certain promise. This is part of OpenBSD's pledge() as well,
which served as basis for Serenity's.
This commit is contained in:
Linus Groh 2021-01-25 22:42:36 +01:00 committed by Andreas Kling
parent b580c005f1
commit 629180b7d8
2 changed files with 5 additions and 9 deletions

View file

@ -67,29 +67,24 @@ int Process::sys$pledge(Userspace<const Syscall::SC_pledge_params*> user_params)
return true;
};
u32 new_promises;
u32 new_execpromises;
u32 new_promises = 0;
u32 new_execpromises = 0;
if (!promises.is_null()) {
new_promises = 0;
if (!parse_pledge(promises, new_promises))
return -EINVAL;
if (m_promises && (!new_promises || new_promises & ~m_promises))
return -EPERM;
} else {
new_promises = m_promises;
}
if (!execpromises.is_null()) {
new_execpromises = 0;
if (!parse_pledge(execpromises, new_execpromises))
return -EINVAL;
if (m_execpromises && (!new_execpromises || new_execpromises & ~m_execpromises))
return -EPERM;
} else {
new_execpromises = m_execpromises;
}
m_has_promises = true;
m_promises = new_promises;
m_execpromises = new_execpromises;