Skip to content

Commit aa67c54

Browse files
Thomas Gleixnergregkh
authored andcommitted
rseq: Set rseq::cpu_id_start to 0 on unregistration
commit 2cb68e4 upstream. The RSEQ rework changed that to RSEQ_CPU_UNINITILIZED, which is obviously incompatible. Revert back to the original behavior. Fixes: 0f085b4 ("rseq: Provide and use rseq_set_ids()") Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Tested-by: Dmitry Vyukov <dvyukov@google.com> Link: https://patch.msgid.link/20260428224427.271566313%40kernel.org Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f630d65 commit aa67c54

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

kernel/rseq.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ static int __init rseq_debugfs_init(void)
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)
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
}

0 commit comments

Comments
 (0)