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
236236 }
237237 __initcall(rseq_debugfs_init);
238238
239−static 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−
244239 static bool rseq_handle_cs(struct task_struct *t, struct pt_regs *regs)
245240 {
246241 struct rseq __user *urseq = t->rseq.usrptr;
@@ -384,19 +379,22 @@ void rseq_syscall(struct pt_regs *regs) · 137 unmodified lines
384379
385380 static bool rseq_reset_ids(void)
386381 {
387− struct rseq_ids ids = {
388− .cpu_id = RSEQ_CPU_ID_UNINITIALIZED,
389− .mm_cid = 0,
390− };
382+ struct rseq __user *rseq = current->rseq.usrptr;
391383
392384 /*
393385 * If this fails, terminate it because this leaves the kernel in
394386 * stupid state as exit to user space will try to fixup the ids
395387 * again.
396388 */
397− if (rseq_set_ids(current, &ids, 0))
398− return true;
389+ scoped_user_rw_access(rseq, efault) {
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;
399396
397+efault:
400398 force_sig(SIGSEGV);
401399 return false;
402400 }