From nobody Mon Jun 8 04:19:59 2026 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4B0F36826E for ; Tue, 2 Jun 2026 03:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780369747; cv=none; b=OIE/dyLpMFBk1vCyhAjmwY6r98nd71HBZjf5TdeThdi4b2EtxVHbLNyJm6IFzyksGT8+ipt1sRM8HZ3Kv838B+VPMmdZbKIH3q6bDrYu+6cW+pKJ1cmltOE76rA0gzIsd3U28J/SCH6Gn1L/nDfD4oihj3aDsjRN25nYw1jl5YQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780369747; c=relaxed/simple; bh=S+5yjiqdurSwWGV3vZL82sGJRrRg3cT3Gkw6FXUX4Zw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NVzdWo7pqV876dJY0ChiCynpNT+5dso01lWzFwNQz17fUFYJ19JPuPjMUOmodMamBlHkzq4xI0rCls9HqwOEcavOR0qgzq5AhAZw6m/SzsLI6gmQ8Fr8YJu0XHZ0zbbWWYaZNqBHtzbH5ck5HCK2uGB5oxmaklQmRtu6CDYYkJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XKg2ss1B; arc=none smtp.client-ip=209.85.215.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XKg2ss1B" Received: by mail-pg1-f194.google.com with SMTP id 41be03b00d2f7-c85a2c012e5so707936a12.1 for ; Mon, 01 Jun 2026 20:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780369745; x=1780974545; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A6//D+s1eomSFlvy221abQe65GjmCnQrDuYTvNngqlI=; b=XKg2ss1BoPVzgtOmaaQ0LMBN0tEJVvzfpgPXVm7seC5aX9pkFnG3xdpZIjUiJ/tre0 TJDME6yQKVSZ8KNqJ2QPEEmpIQhGc0bP6H9gijXkC6amEQ2LfbQvehA88RRoZgqY6koX 15g5eC/CvktpPj2FhjlfB4KWmf+YiwWCoZDtPAtv1LNE7tHFLqCxWMGPBaCZymI4KZWF 4NavlPs7JhAaGk5wIaaiv5ntgwaswuEfD3oCxRB7FagHkGao8uaQG2hQkYL9AUaD1nzh zL/2t1qFIUnzC919sKHG49Vf/HwZPARH0AtxpxRH8LEIvdB76aBF1DoHNVbdhXGrL03D XvmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780369745; x=1780974545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=A6//D+s1eomSFlvy221abQe65GjmCnQrDuYTvNngqlI=; b=l2zkFjtpc317hykPj/klCyvb/4ET+S5xb0PfZrLQwCWlHJMYmT54MeOtSh5g2iNcFF SvYVMoxq8kqVOareBZTtZBkwzckxov+Cfh6mZxg8jT21zvwWgNx08GSSqRJIfHv6gQK5 gAP4sORBdf+ldqXKEB8x2dldmkVUv4sHFo0u4bPATJIFv63j7TG9rp7thsDAQxnBxnLB epBuAFb38SmNPzF2eb1V9d745bywpRtYuS+yvCdG3GjZYJ5bgEfQT2z2XiX9JQUGyG4d Q1/2Aa+wfFsD7gmeQQ+K9LFSWIuSF5Me8s6tEONcV1deffrPOA/W8gswKuzp5kswZGyl mUig== X-Forwarded-Encrypted: i=1; AFNElJ/dKg+/TtGhd1I6mwPDIMNqwJcrVZBWFETXS7njX6FGHZZg/Z1qPMgU4mEG8QeFaOsTBzKtS2X6mB4mnSg=@vger.kernel.org X-Gm-Message-State: AOJu0YwaWM/Pgf/Npta//qCxoPD3yvDqquLUGCfyk9R3KdqVNgcXllRY A3gwsq32TmDrBw7eBRRk6E/wo1NDweifmGY4jiDep6kUDEvEIgzZbQv/ X-Gm-Gg: Acq92OGobi/Qh1BTXM+mMR49ncwKpmwQyOUNeMxZB8hQujtxRBj5JKyn8HlKLBFA1oo wSU1kc9vpFjq6VrsVKMpPnEVni7CTf504+JHDExvntquaRtZGAsYGnTs7ioWYYKn9H+YmIltSH2 Cyo/ge9Aa5/j8vUpTuW5hgtphn0LhZP6qr1dlQTqY+T1pzxP2A1quhOtbek5eRI3iMbvtNgaGfI TV2DSVVma/g9EYWijuVNu6bR5T5vE+y2SiahDnmbFS6+oE9fz0oOF0khZ9xlKFh0qwQWVyZnLOc hsdZJexnaumzn5qNeFFWsHVTi22UtPsazxxoyB7fUdeUelR5t5/TbmwTi9eA5sc6TpXypoMGt2W KznEsinykaMixh1JPExmYgylt+2X6CW8XwlRe3tYN62wh1IYx2pne4uOIwGGge0B4CBbiUcSpDu mGifDH4DDeXiSzmeMmxmyayCyp9NXtWfDt/3i+eLZ0f8S4+fjAhDpKUfCkoBgf X-Received: by 2002:a05:6a20:4389:b0:398:7ffe:472f with SMTP id adf61e73a8af0-3b427bc7337mr14542220637.2.1780369745002; Mon, 01 Jun 2026 20:09:05 -0700 (PDT) Received: from lima-ubuntu.hz.ali.com ([47.246.98.221]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85861d5fe2sm8836799a12.8.2026.06.01.20.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2026 20:09:04 -0700 (PDT) From: Qing Wang To: peterz@infradead.org, mathieu.desnoyers@efficios.com Cc: dvyukov@google.com, justinstitt@google.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, mark.rutland@arm.com, mingo@kernel.org, morbo@google.com, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, syzbot+185a631927096f9da2fc@syzkaller.appspotmail.com, tglx@kernel.org, wangqing7171@gmail.com Subject: [PATCH v2] rseq: fix using an uninitialized stack variable in rseq_exit_user_update Date: Tue, 2 Jun 2026 11:08:54 +0800 Message-Id: <20260602030854.574038-1-wangqing7171@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260601143934.GT3493090@noisy.programming.kicks-ass.net> References: <20260601143934.GT3493090@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_e= ntry.h:502 [inline] The local variable: ```c struct rseq_ids ids =3D { .cpu_id =3D task_cpu(t), .mm_cid =3D task_mm_cid(t), .node_id =3D 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=3D185a631927096f9da2fc Fixes: 82f572449cfe ("rseq: Implement read only ABI enforcement for optimiz= ed RSEQ V2 mode") Signed-off-by: Qing Wang Acked-by: Mark Rutland --- include/linux/rseq_entry.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/rseq_entry.h b/include/linux/rseq_entry.h index 63bc72086e75..ed9da6e41a2a 100644 --- a/include/linux/rseq_entry.h +++ b/include/linux/rseq_entry.h @@ -635,10 +635,11 @@ static __always_inline bool rseq_exit_user_update(str= uct pt_regs *regs, struct t return true; } =20 + int cpu =3D task_cpu(t); struct rseq_ids ids =3D { - .cpu_id =3D task_cpu(t), + .cpu_id =3D cpu, .mm_cid =3D task_mm_cid(t), - .node_id =3D cpu_to_node(ids.cpu_id), + .node_id =3D cpu_to_node(cpu), }; =20 return rseq_update_usr(t, regs, &ids); --=20 2.34.1