summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-07-09 21:39:40 +0000
committerkib <kib@FreeBSD.org>2014-07-09 21:39:40 +0000
commit729061be23933eef604d4544c9dcbfbdbfae737e (patch)
tree6b2134ae407819edaf1c50b982dde95b46f6672b /sys/amd64
parent9b45140041c09da644d27b76a72bd4d08340b70c (diff)
downloadFreeBSD-src-729061be23933eef604d4544c9dcbfbdbfae737e.zip
FreeBSD-src-729061be23933eef604d4544c9dcbfbdbfae737e.tar.gz
For safety, ensure that any consumer of the set_regs() and
ptrace_set_pc() use the correct return to userspace using iret. The signal return, PT_CONTINUE (which in fact uses signal return path) set the pcb flag already. The setcontext(2) enforces iret return when %rip is incorrect. Due to this, the change is redundand, but is made to ensure that no path which modifies context, forgets to set PCB_FULL_IRET. Inspired by: CVE-2014-4699 Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/machdep.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 82c2c89..5afd58c 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -2144,7 +2144,9 @@ makectx(struct trapframe *tf, struct pcb *pcb)
int
ptrace_set_pc(struct thread *td, unsigned long addr)
{
+
td->td_frame->tf_rip = addr;
+ set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (0);
}
@@ -2244,8 +2246,8 @@ set_regs(struct thread *td, struct reg *regs)
tp->tf_fs = regs->r_fs;
tp->tf_gs = regs->r_gs;
tp->tf_flags = TF_HASSEGS;
- set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
}
+ set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (0);
}
OpenPOWER on IntegriCloud