All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rseq: fix using an uninitialized stack variable in rseq_exit_user_update
@ 2026-06-01  2:13 Qing Wang
  2026-06-01 13:59 ` Mathieu Desnoyers
  0 siblings, 1 reply; 11+ messages in thread
From: Qing Wang @ 2026-06-01  2:13 UTC (permalink / raw)
  To: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Peter Zijlstra, Thomas Gleixner, Mathieu Desnoyers, Ingo Molnar,
	Dmitry Vyukov, Mark Rutland
  Cc: linux-kernel, llvm, Qing Wang, syzbot+185a631927096f9da2fc

There is an bug which is an uninitialized stack variable use in
`rseq_exit_user_update()` reported by syzbot:

BUG: KMSAN: kernel-infoleak in rseq_set_ids_get_csaddr include/linux/rseq_entry.h:502 [inline]

The local variable:
```c
	struct rseq_ids ids = {
		.cpu_id	 = task_cpu(t),
		.mm_cid	 = task_mm_cid(t),
		.node_id = cpu_to_node(ids.cpu_id),
	};
```
According to the C standard, the evaluation order of expressions in an
initializer list is indeterminately sequenced. The compiler (Clang, in this
KMSAN build) evaluates `cpu_to_node(ids.cpu_id)` *before* `ids.cpu_id` is
initialized with `task_cpu(t)`.

This is fixed by moving the assignment of ids.node_id outside the structure
initialization.

Reported-by: syzbot+185a631927096f9da2fc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=185a631927096f9da2fc
Fixes: 82f572449cfe ("rseq: Implement read only ABI enforcement for optimized RSEQ V2 mode")
Signed-off-by: Qing Wang <wangqing7171@gmail.com>
---
 include/linux/rseq_entry.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/rseq_entry.h b/include/linux/rseq_entry.h
index 63bc72086e75..e05f4c18f39e 100644
--- a/include/linux/rseq_entry.h
+++ b/include/linux/rseq_entry.h
@@ -638,8 +638,8 @@ static __always_inline bool rseq_exit_user_update(struct pt_regs *regs, struct t
 	struct rseq_ids ids = {
 		.cpu_id	 = task_cpu(t),
 		.mm_cid	 = task_mm_cid(t),
-		.node_id = cpu_to_node(ids.cpu_id),
 	};
+	ids.node_id = cpu_to_node(ids.cpu_id);
 
 	return rseq_update_usr(t, regs, &ids);
 efault:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-06-20 19:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-01  2:13 [PATCH] rseq: fix using an uninitialized stack variable in rseq_exit_user_update Qing Wang
2026-06-01 13:59 ` Mathieu Desnoyers
2026-06-01 14:39   ` Peter Zijlstra
2026-06-02  3:08     ` [PATCH v2] " Qing Wang
2026-06-02 10:08       ` Mark Rutland
2026-06-02 10:42       ` Peter Zijlstra
2026-06-19 12:45         ` Tetsuo Handa
2026-06-19 19:32           ` Thomas Gleixner
2026-06-19 22:34             ` Tetsuo Handa
2026-06-20 19:51               ` Thomas Gleixner
2026-06-02 10:45       ` [tip: sched/urgent] rseq: Fix using an uninitialized stack variable in rseq_exit_user_update() tip-bot2 for Qing Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.