mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
Kernel: Only allow sending signals to process you own.
This commit is contained in:
parent
05f9257621
commit
c09ab7cc40
2 changed files with 15 additions and 6 deletions
|
@ -1411,6 +1411,8 @@ int Process::sys$isatty(int fd)
|
||||||
|
|
||||||
int Process::sys$kill(pid_t pid, int signal)
|
int Process::sys$kill(pid_t pid, int signal)
|
||||||
{
|
{
|
||||||
|
if (signal < 0 || signal >= 32)
|
||||||
|
return -EINVAL;
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
// FIXME: Send to same-group processes.
|
// FIXME: Send to same-group processes.
|
||||||
ASSERT(pid != 0);
|
ASSERT(pid != 0);
|
||||||
|
@ -1424,13 +1426,18 @@ int Process::sys$kill(pid_t pid, int signal)
|
||||||
Scheduler::yield();
|
Scheduler::yield();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Process* peer = nullptr;
|
InterruptDisabler disabler;
|
||||||
{
|
auto* peer = Process::from_pid(pid);
|
||||||
InterruptDisabler disabler;
|
|
||||||
peer = Process::from_pid(pid);
|
|
||||||
}
|
|
||||||
if (!peer)
|
if (!peer)
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
|
// FIXME: Allow sending SIGCONT to everyone in the process group.
|
||||||
|
// FIXME: Should setuid processes have some special treatment here?
|
||||||
|
if (!is_superuser() && m_euid != peer->m_uid && m_uid != peer->m_uid)
|
||||||
|
return -EPERM;
|
||||||
|
if (peer->is_ring0() && signal == SIGKILL) {
|
||||||
|
kprintf("%s(%u) attempted to send SIGKILL to ring 0 process %s(%u)\n", name().characters(), m_pid, peer->name().characters(), peer->pid());
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
peer->send_signal(signal, this);
|
peer->send_signal(signal, this);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,9 @@ int main(int argc, char** argv)
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
kill((pid_t)pid, signum);
|
int rc = kill((pid_t)pid, signum);
|
||||||
|
if (rc < 0)
|
||||||
|
perror("kill");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue