MFamd64: Check for invalid flags in the machine context in sigreturn()

and setcontext().
This commit is contained in:
John Baldwin 2014-11-25 12:52:00 +00:00
parent 521b1af4ea
commit fbdb0b778a

View File

@ -1060,6 +1060,11 @@ sys_sigreturn(td, uap)
if (error != 0) if (error != 0)
return (error); return (error);
ucp = &uc; ucp = &uc;
if ((ucp->uc_mcontext.mc_flags & ~_MC_FLAG_MASK) != 0) {
uprintf("pid %d (%s): sigreturn mc_flags %x\n", p->p_pid,
td->td_name, ucp->uc_mcontext.mc_flags);
return (EINVAL);
}
regs = td->td_frame; regs = td->td_frame;
eflags = ucp->uc_mcontext.mc_eflags; eflags = ucp->uc_mcontext.mc_eflags;
if (eflags & PSL_VM) { if (eflags & PSL_VM) {
@ -3858,7 +3863,8 @@ set_mcontext(struct thread *td, const mcontext_t *mcp)
int eflags, ret; int eflags, ret;
tp = td->td_frame; tp = td->td_frame;
if (mcp->mc_len != sizeof(*mcp)) if (mcp->mc_len != sizeof(*mcp) ||
(mcp->mc_flags & ~_MC_FLAG_MASK) != 0)
return (EINVAL); return (EINVAL);
eflags = (mcp->mc_eflags & PSL_USERCHANGE) | eflags = (mcp->mc_eflags & PSL_USERCHANGE) |
(tp->tf_eflags & ~PSL_USERCHANGE); (tp->tf_eflags & ~PSL_USERCHANGE);