Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw: sanitize Kernel::Cpu::Context aka Kernel::Cpu_context #5319

Open
skalk opened this issue Aug 13, 2024 · 0 comments
Open

hw: sanitize Kernel::Cpu::Context aka Kernel::Cpu_context #5319

skalk opened this issue Aug 13, 2024 · 0 comments
Labels

Comments

@skalk
Copy link
Member

skalk commented Aug 13, 2024

The current class Kernel::Cpu_job shall be named Kernel::Cpu::Context consistently (like Kernel::Scheduler::Context). Unfortunately, we cannot define it as inner class of Kernel::Cpu, because of inheritance relations of Thread to Cpu::Context and Cpu::Idle_thread to Thread.
Anyway, at least we can name it Kernel::Cpu_context and provide a Cpu::Context alias.

More important, this class contains a pointer to a Kernel::Cpu object. This needs to be a pointer in case the affinity of the context change. Nonetheless, the pointer is directly useable by its class derivates, and heavily de-referenced without any check. Instead of using a lot of pointer sanity checks (or lambda for it), we should ensure that the Cpu pointer is set correctly at construction time, and always stays valid. Therefore, the Cpu affinity needs to be given with the Thread creation syscall, and not via the Thread start syscall.

@skalk skalk added the cleanup label Aug 13, 2024
skalk added a commit to skalk/genode that referenced this issue Aug 13, 2024
skalk added a commit to skalk/genode that referenced this issue Aug 13, 2024
* Rename Kernel::Cpu_job to Kernel::Cpu_context (alias Kernel::Cpu::Context)
* State first Cpu affinity of Cpu::Context at construction time
* Move cpu affinity argument from kernel syscall create_thread to start_thread
* Ensure that Cpu pointer is always valid

Fix genodelabs#5319
skalk added a commit to skalk/genode that referenced this issue Aug 13, 2024
skalk added a commit to skalk/genode that referenced this issue Aug 13, 2024
* Rename Kernel::Cpu_job to Kernel::Cpu_context (alias Kernel::Cpu::Context)
* State first Cpu affinity of Cpu::Context at construction time
* Move cpu affinity argument from kernel syscall create_thread to start_thread
* Ensure that Cpu pointer is always valid

Fix genodelabs#5319
@chelmuth chelmuth changed the title hw: sanitze Kernel::Cpu::Context aka Kernel::Cpu_context hw: sanitize Kernel::Cpu::Context aka Kernel::Cpu_context Aug 14, 2024
skalk added a commit to skalk/genode that referenced this issue Aug 16, 2024
skalk added a commit to skalk/genode that referenced this issue Aug 16, 2024
* Rename Kernel::Cpu_job to Kernel::Cpu_context (alias Kernel::Cpu::Context)
* State first Cpu affinity of Cpu::Context at construction time
* Move cpu affinity argument from kernel syscall create_thread to start_thread
* Ensure that Cpu pointer is always valid

Fix genodelabs#5319
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant