History

rseq: Set rseq::cpu_id_start to 0 on unregistration

The RSEQ rework changed that to RSEQ_CPU_UNINITILIZED, which is obviously incompatible. Revert back to the original behavior.

Thomas Gleixner committed 6 months ago

Commit 2cb68e41 parent cb488281 file · +9 −11Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/rseq.c+9−11
@@ -236,11 +236,6 @@ static int __init rseq_debugfs_init(void) · 235 unmodified lines
236}236}
237__initcall(rseq_debugfs_init);237__initcall(rseq_debugfs_init);
238 238
239static bool rseq_set_ids(struct task_struct *t, struct rseq_ids *ids, u32 node_id)
240{
241 return rseq_set_ids_get_csaddr(t, ids, node_id, NULL);
242}
243
244static bool rseq_handle_cs(struct task_struct *t, struct pt_regs *regs)239static bool rseq_handle_cs(struct task_struct *t, struct pt_regs *regs)
245{240{
246 struct rseq __user *urseq = t->rseq.usrptr;241 struct rseq __user *urseq = t->rseq.usrptr;
@@ -384,19 +379,22 @@ void rseq_syscall(struct pt_regs *regs) · 137 unmodified lines
384 379
385static bool rseq_reset_ids(void)380static bool rseq_reset_ids(void)
386{381{
387 struct rseq_ids ids = {382 struct rseq __user *rseq = current->rseq.usrptr;
388 .cpu_id = RSEQ_CPU_ID_UNINITIALIZED,
389 .mm_cid = 0,
390 };
391 383
392 /*384 /*
393 * If this fails, terminate it because this leaves the kernel in385 * If this fails, terminate it because this leaves the kernel in
394 * stupid state as exit to user space will try to fixup the ids386 * stupid state as exit to user space will try to fixup the ids
395 * again.387 * again.
396 */388 */
397 if (rseq_set_ids(current, &ids, 0))389 scoped_user_rw_access(rseq, efault) {
398 return true;390 unsafe_put_user(0, &rseq->cpu_id_start, efault);
391 unsafe_put_user(RSEQ_CPU_ID_UNINITIALIZED, &rseq->cpu_id, efault);
392 unsafe_put_user(0, &rseq->node_id, efault);
393 unsafe_put_user(0, &rseq->mm_cid, efault);
394 }
395 return true;
399 396
397efault:
400 force_sig(SIGSEGV);398 force_sig(SIGSEGV);
401 return false;399 return false;
402}400}