Skip to content

Commit

Permalink
caprevoke: stop and scan all procs sharing our vmspace
Browse files Browse the repository at this point in the history
In addition to thread_single() on the revoking process, call
stop_vmspace_proc() to stop all other processes that share our
vmspace.  Then revoke the horders for each thread and process sharing
the vmspace.
  • Loading branch information
brooksdavis committed Jul 25, 2024
1 parent fdb9c4b commit 159c084
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions sys/kern/kern_cheri_revoke.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ kern_cheri_revoke(struct thread *td, int flags,
#else
struct cheri_revoke_stats *crstp = NULL;
#endif
struct proc *proc;
struct vmspace *vm;
vm_map_t vmm;
struct vm_cheri_revoke_cookie vmcrc;
Expand Down Expand Up @@ -613,6 +614,7 @@ kern_cheri_revoke(struct thread *td, int flags,
return (ERESTART);
}
}
stop_vmspace_proc(td->td_proc);

/*
* Drop the process lock *then* iterate the threads in this
Expand All @@ -635,20 +637,27 @@ kern_cheri_revoke(struct thread *td, int flags,
* This also risks the use of ptrace() to expose to userspace
* the trap frame of a stalled thread that has not yet scanned
* itself. Yick.
*
* XXX-BD: is it safe to walk the proc list and run the
* revokers or do we need to PHOLD them first?
*/

_PHOLD(td->td_proc);
PROC_UNLOCK(td->td_proc);

/* Per-thread kernel hoarders */
FOREACH_THREAD_IN_PROC (td->td_proc, ptd) {
cheri_revoke_td_frame(ptd, &vmcrc);
sig_thread_cheri_revoke(ptd, &vmcrc);
LIST_FOREACH(proc, &td->td_proc->p_vmspace->vm_proclist,
p_vm_proclist) {
FOREACH_THREAD_IN_PROC (proc, ptd) {

Check failure on line 651 in sys/kern/kern_cheri_revoke.c

View workflow job for this annotation

GitHub Actions / Style Checker

space prohibited between function name and open parenthesis '('
cheri_revoke_td_frame(ptd, &vmcrc);
sig_thread_cheri_revoke(ptd, &vmcrc);
}
}
}

/* Per-process kernel hoarders */
cheri_revoke_hoarders(td->td_proc, &vmcrc);
LIST_FOREACH(proc, &td->td_proc->p_vmspace->vm_proclist, p_vm_proclist)
cheri_revoke_hoarders(proc, &vmcrc);

KASSERT(myst == CHERI_REVOKE_ST_INITING ||
myst == CHERI_REVOKE_ST_CLOSING,
Expand Down Expand Up @@ -686,6 +695,7 @@ kern_cheri_revoke(struct thread *td, int flags,

PROC_LOCK(td->td_proc);
_PRELE(td->td_proc);
resume_vmspace_proc(td->td_proc);
if ((td->td_proc->p_flag & P_HADTHREADS) != 0) {
thread_single_end(td->td_proc, SINGLE_BOUNDARY);
}
Expand Down

0 comments on commit 159c084

Please sign in to comment.