Index: sys/amd64/amd64/exec_machdep.c =================================================================== --- sys/amd64/amd64/exec_machdep.c +++ sys/amd64/amd64/exec_machdep.c @@ -196,8 +196,10 @@ (xfpusave != NULL && copyout(xfpusave, (void *)sf.sf_uc.uc_mcontext.mc_xfpustate, xfpusave_len) != 0)) { +#ifdef DEBUG uprintf("pid %d comm %s has trashed its stack, killing\n", p->p_pid, p->p_comm); +#endif PROC_LOCK(p); sigexit(td, SIGILL); } @@ -245,14 +247,18 @@ error = copyin(uap->sigcntxp, &uc, sizeof(uc)); if (error != 0) { +#ifdef DEBUG uprintf("pid %d (%s): sigreturn copyin failed\n", p->p_pid, td->td_name); +#endif return (error); } ucp = &uc; if ((ucp->uc_mcontext.mc_flags & ~_MC_FLAG_MASK) != 0) { +#ifdef DEBUG uprintf("pid %d (%s): sigreturn mc_flags %x\n", p->p_pid, td->td_name, ucp->uc_mcontext.mc_flags); +#endif return (EINVAL); } regs = td->td_frame; @@ -261,8 +267,10 @@ * Don't allow users to change privileged or reserved flags. */ if (!EFL_SECURE(rflags, regs->tf_rflags)) { +#ifdef DEBUG uprintf("pid %d (%s): sigreturn rflags = 0x%lx\n", p->p_pid, td->td_name, rflags); +#endif return (EINVAL); } @@ -273,8 +281,10 @@ */ cs = ucp->uc_mcontext.mc_cs; if (!CS_SECURE(cs)) { +#ifdef DEBUG uprintf("pid %d (%s): sigreturn cs = 0x%x\n", p->p_pid, td->td_name, cs); +#endif ksiginfo_init_trap(&ksi); ksi.ksi_signo = SIGBUS; ksi.ksi_code = BUS_OBJERR; @@ -288,8 +298,10 @@ xfpustate_len = uc.uc_mcontext.mc_xfpustate_len; if (xfpustate_len > cpu_max_ext_state_size - sizeof(struct savefpu)) { +#ifdef DEBUG uprintf("pid %d (%s): sigreturn xfpusave_len = 0x%zx\n", p->p_pid, td->td_name, xfpustate_len); +#endif return (EINVAL); } xfpustate = (char *)fpu_save_area_alloc(); @@ -297,9 +309,11 @@ xfpustate, xfpustate_len); if (error != 0) { fpu_save_area_free((struct savefpu *)xfpustate); +#ifdef DEBUG uprintf( "pid %d (%s): sigreturn copying xfpustate failed\n", p->p_pid, td->td_name); +#endif return (error); } } else { @@ -309,8 +323,10 @@ ret = set_fpcontext(td, &ucp->uc_mcontext, xfpustate, xfpustate_len); fpu_save_area_free((struct savefpu *)xfpustate); if (ret != 0) { +#ifdef DEBUG uprintf("pid %d (%s): sigreturn set_fpcontext err %d\n", p->p_pid, td->td_name, ret); +#endif return (ret); } bcopy(&ucp->uc_mcontext.mc_rdi, regs, sizeof(*regs)); Index: sys/amd64/linux/linux_sysvec.c =================================================================== --- sys/amd64/linux/linux_sysvec.c +++ sys/amd64/linux/linux_sysvec.c @@ -556,8 +556,10 @@ * one less debugger trap, so allowing it is fairly harmless. */ if (!EFL_SECURE(rflags & ~PSL_RF, regs->tf_rflags & ~PSL_RF)) { +#ifdef DEBUG uprintf("pid %d comm %s linux mangled rflags %#lx\n", p->p_pid, p->p_comm, rflags); +#endif return (EINVAL); } @@ -567,8 +569,10 @@ * other selectors, invalid %eip's and invalid %esp's. */ if (!CS_SECURE(context->sc_cs)) { +#ifdef DEBUG uprintf("pid %d comm %s linux mangled cs %#x\n", p->p_pid, p->p_comm, context->sc_cs); +#endif ksiginfo_init_trap(&ksi); ksi.ksi_signo = SIGBUS; ksi.ksi_code = BUS_OBJERR;