1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 06:34:57 +00:00

Kernel+Userland: Remove the {get,set}_thread_name syscalls

These syscalls are not necessary on their own, and they give the false
impression that a caller could set or get the thread name of any process
in the system, which is not true.

Therefore, move the functionality of these syscalls to be options in the
prctl syscall, which makes it abundantly clear that these operations
could only occur from a running thread in a process that sees other
threads in that process only.
This commit is contained in:
Liav A 2023-08-19 21:10:25 +03:00 committed by Tim Schumacher
parent 1458849850
commit 1c0aa51684
14 changed files with 54 additions and 63 deletions

View file

@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <syscall.h>
#include <time.h>
#include <unistd.h>
@ -547,13 +548,13 @@ int pthread_setname_np(pthread_t thread, char const* name)
{
if (!name)
return EFAULT;
int rc = syscall(SC_set_thread_name, thread, name, strlen(name));
int rc = prctl(PR_SET_THREAD_NAME, thread, name, strlen(name));
__RETURN_PTHREAD_ERROR(rc);
}
int pthread_getname_np(pthread_t thread, char* buffer, size_t buffer_size)
{
int rc = syscall(SC_get_thread_name, thread, buffer, buffer_size);
int rc = prctl(PR_GET_THREAD_NAME, thread, buffer, buffer_size);
__RETURN_PTHREAD_ERROR(rc);
}

View file

@ -19,10 +19,11 @@ int prctl(int option, ...)
uintptr_t arg1 = va_arg(args, uintptr_t);
uintptr_t arg2 = va_arg(args, uintptr_t);
uintptr_t arg3 = va_arg(args, uintptr_t);
va_end(args);
int rc = syscall(SC_prctl, option, arg1, arg2);
int rc = syscall(SC_prctl, option, arg1, arg2, arg3);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}