Kernel: Disable x86 RDTSC instruction in userspace

It's still possible to read the TSC via the read_tsc() syscall, but we
will now clear some of the bottom bits for unprivileged users.
This commit is contained in:
Andreas Kling 2020-01-01 18:18:02 +01:00
commit 38f93ef13b
Notes: sideshowbarker 2024-07-19 10:28:41 +09:00
6 changed files with 25 additions and 1 deletions

View file

@ -2452,6 +2452,8 @@ int Process::sys$read_tsc(u32* lsw, u32* msw)
if (!validate_write_typed(msw))
return -EFAULT;
read_tsc(*lsw, *msw);
if (!is_superuser())
*lsw &= ~0xfff;
return 0;
}