Kernel: If userspace sets fs or gs, dont overwrite it

Current cpu index is stored at either segment. If userspace sets that
segment, kernel will not overwrite it on every reschedule. This is fine
as long as user program does not use anything that relies on it :)
This commit is contained in:
2026-04-04 23:35:33 +03:00
parent d7e292a9f8
commit df257755f7
3 changed files with 16 additions and 2 deletions

View File

@@ -3302,7 +3302,9 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_set_fsbase(void* addr)
{
Thread::current().set_fsbase(reinterpret_cast<vaddr_t>(addr));
auto& thread = Thread::current();
thread.m_has_custom_fsbase = true;
thread.set_fsbase(reinterpret_cast<vaddr_t>(addr));
Processor::load_fsbase();
return 0;
}
@@ -3314,7 +3316,9 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_set_gsbase(void* addr)
{
Thread::current().set_gsbase(reinterpret_cast<vaddr_t>(addr));
auto& thread = Thread::current();
thread.m_has_custom_gsbase = true;
thread.set_gsbase(reinterpret_cast<vaddr_t>(addr));
Processor::load_gsbase();
return 0;
}