Skip to content

Commit 862de4d

Browse files
committed
Fix bounds for td_frame
1 parent 38e1dd2 commit 862de4d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sys/arm64/arm64/vm_machdep.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
124124
ptrauth_fork(td2, td1);
125125
#endif
126126

127+
#ifdef CHERI_BOUNDED_KSTACK
128+
tf = (struct trapframe *)STACKALIGN(
129+
(struct trapframe *)cheri_address_set(td2->td_kstack,
130+
(ptraddr_t)pcb2) - 1);
131+
tf = cheri_bounds_set_exact(tf, sizeof(struct trapframe));
132+
#else
127133
tf = (struct trapframe *)STACKALIGN((struct trapframe *)pcb2 - 1);
134+
#endif
128135
bcopy(td1->td_frame, tf, sizeof(*tf));
129136
tf->tf_x[0] = 0;
130137
tf->tf_x[1] = 0;
@@ -135,10 +142,6 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
135142
);
136143

137144
td2->td_frame = tf;
138-
#ifdef CHERI_BOUNDED_KSTACK
139-
td2->td_frame = cheri_bounds_set_exact(td2->td_frame,
140-
sizeof(struct trapframe));
141-
#endif
142145

143146
/* Set the return value registers for fork() */
144147
td2->td_pcb->pcb_x[PCB_X19] = (uintptr_t)fork_return;

0 commit comments

Comments
 (0)