From b94904a660d283b4079c76b7ec89b7f6600a4436 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sun, 23 Jun 2024 23:17:26 +0200 Subject: [PATCH] Use correct addrsp when setting sighandler. --- src/scheme/proc.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index b5ea14a9ed..5a36d1513f 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -1133,6 +1133,9 @@ impl KernelScheme for ProcScheme { if data.user_handler >= crate::USER_END_OFFSET || data.excp_handler >= crate::USER_END_OFFSET { return Err(Error::new(EPERM)); } + if data.thread_control_addr >= crate::USER_END_OFFSET || data.proc_control_addr >= crate::USER_END_OFFSET { + return Err(Error::new(EFAULT)); + } let state = if data.thread_control_addr != 0 && data.proc_control_addr != 0 { let offset = u16::try_from(data.thread_control_addr % PAGE_SIZE).unwrap(); @@ -1146,8 +1149,12 @@ impl KernelScheme for ProcScheme { } }; - let addrsp = AddrSpace::current()?; - + let addrsp = Arc::clone( + context::contexts().get(info.pid) + .ok_or(Error::new(ESRCH))? + .read() + .addr_space()? + ); Some(SignalState { threadctl_off: validate_off(data.thread_control_addr, mem::size_of::())?,