From 80b991dc09852122e4940e375a5108b599eff593 Mon Sep 17 00:00:00 2001 From: Ryan Daum Date: Sun, 24 Nov 2024 12:51:10 -0500 Subject: [PATCH] Fix to permissions propagation up the stack with set_task_perms --- crates/kernel/src/vm/exec_state.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/kernel/src/vm/exec_state.rs b/crates/kernel/src/vm/exec_state.rs index 948584ea..b8957157 100644 --- a/crates/kernel/src/vm/exec_state.rs +++ b/crates/kernel/src/vm/exec_state.rs @@ -161,7 +161,14 @@ impl VMExecState { /// Update the permissions of the current task, as called by the `set_task_perms` /// built-in. pub(crate) fn set_task_perms(&mut self, perms: Objid) { - self.top_mut().permissions = perms; + // Copy the stack perms up to the last non-builtin. That is, make sure builtin-frames + // get the permissions update, and the first non-builtin, too. + for activation in self.stack.iter_mut().rev() { + activation.permissions = perms; + if !activation.is_builtin_frame() { + break; + } + } } /// Push a value onto the value stack