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
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275035

View File

@ -1060,6 +1060,11 @@ sys_sigreturn(td, uap)
if (error != 0)
return (error);
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;
eflags = ucp->uc_mcontext.mc_eflags;
if (eflags & PSL_VM) {
@ -3858,7 +3863,8 @@ set_mcontext(struct thread *td, const mcontext_t *mcp)
int eflags, ret;
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);
eflags = (mcp->mc_eflags & PSL_USERCHANGE) |
(tp->tf_eflags & ~PSL_USERCHANGE);