arm64 makectx: Fix overflow of tf_x array
PCB_LR isn't stored in tf_x, so trying to store it as pcb_x[PCB_LR] = tf->tf_x[PCB_LR + PCB_X_START] overflowed the tf_x array. Reported by: Morello (bounds check crash) Reviewed by: jrtc27, andrew, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D41485
This commit is contained in:
parent
5635d5b61e
commit
91d0876a20
@ -359,11 +359,14 @@ makectx(struct trapframe *tf, struct pcb *pcb)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nitems(pcb->pcb_x); i++)
|
||||
pcb->pcb_x[i] = tf->tf_x[i + PCB_X_START];
|
||||
|
||||
/* NB: pcb_x[PCB_LR] is the PC, see PC_REGS() in db_machdep.h */
|
||||
pcb->pcb_x[PCB_LR] = tf->tf_elr;
|
||||
for (i = 0; i < nitems(pcb->pcb_x); i++) {
|
||||
if (i == PCB_LR)
|
||||
pcb->pcb_x[i] = tf->tf_elr;
|
||||
else
|
||||
pcb->pcb_x[i] = tf->tf_x[i + PCB_X_START];
|
||||
}
|
||||
|
||||
pcb->pcb_sp = tf->tf_sp;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user