diff options
author | John Baldwin <jhb@FreeBSD.org> | 2020-01-17 19:13:49 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2020-01-17 19:13:49 +0000 |
commit | 7f1c5f36043d4601c08afae8530d90e2d9280c1d (patch) | |
tree | a47bbd020fc34e79753003df963364634a392fe0 | |
parent | ffbf0e3ce4b200ecfffbd20edb9459d799ce72d4 (diff) |
Notes
-rw-r--r-- | sys/riscv/riscv/machdep.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 82812fd137e2..2a4ed10b1def 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -367,6 +367,14 @@ set_mcontext(struct thread *td, mcontext_t *mcp) tf = td->td_frame; + /* + * Make sure the processor mode has not been tampered with and + * interrupts have not been disabled. + * Supervisor interrupts in user mode are always enabled. + */ + if ((mcp->mc_gpregs.gp_sstatus & SSTATUS_SPP) != 0) + return (EINVAL); + memcpy(tf->tf_t, mcp->mc_gpregs.gp_t, sizeof(tf->tf_t)); memcpy(tf->tf_s, mcp->mc_gpregs.gp_s, sizeof(tf->tf_s)); memcpy(tf->tf_a, mcp->mc_gpregs.gp_a, sizeof(tf->tf_a)); @@ -523,22 +531,12 @@ struct sigreturn_args { int sys_sigreturn(struct thread *td, struct sigreturn_args *uap) { - uint64_t sstatus; ucontext_t uc; int error; if (copyin(uap->sigcntxp, &uc, sizeof(uc))) return (EFAULT); - /* - * Make sure the processor mode has not been tampered with and - * interrupts have not been disabled. - * Supervisor interrupts in user mode are always enabled. - */ - sstatus = uc.uc_mcontext.mc_gpregs.gp_sstatus; - if ((sstatus & SSTATUS_SPP) != 0) - return (EINVAL); - error = set_mcontext(td, &uc.uc_mcontext); if (error != 0) return (error); |