From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa2-f0.google.com (mail-oa2-f0.google.com [74.125.231.64]) (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 AB7813AE71F for ; Thu, 8 Oct 2026 16:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.231.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791477653; cv=none; b=sbTT/PM/rF+RAyCzDQCf0UhSMJhQ+E0nALI5JfoXpMUChoSwPI1UCg0DqpI/KofGOSZg/sC6QtX22woDfSMvHrOnyr6e6CUEw2r9qXH6LyOF+AfSnV50uwYzNHdH6/fArtbREXkLRAGcAHIz/NrbE17UyzDBpBd1pGBAIbff3+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791477653; c=relaxed/simple; bh=imWuqE76DrVJWZgCKyCFc7MWU5CZeZEyrJt3Q6oHClQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=djJ1oSSJlC0Td0ecCAEF2Pno/7A7MJgBcwauGKRMYCjwq9O1/o6PNP44ESNmPFMLmSYLagcbl8Nt6HGPAhqnEkvXdVjKECVC2apl56tuaCFYBB0M70Ss/h2hKyjXoVKGpbVsNLNPnF61epX3sICBpSGKhQboO/HjFoayg+I4S6s= 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=K+CYnki3; arc=none smtp.client-ip=74.125.231.64 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="K+CYnki3" Received: by mail-oa2-f0.google.com with SMTP id 586e51a60fabf-44cdbcd53b8so1403903fac.0 for ; Thu, 08 Oct 2026 09:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791477650; x=1792082450; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=HXq065e6nI28MxLdaLNxE40ltfZ0a3n1jeYu75IbvbU=; b=K+CYnki3ljfXAE3w7bhJEn7+yVxxIJgBa/NrLODm4Fs9gBhHngPjEkPCoRRNL3GzYn Vkb6dSVIjQF9gu0GRky5QNjkoxu3Qy3wl35CTm4INWra1fET4e45I/99XIoT/nO3v9G/ NTLvR6CUsayYkNzzrIW7Mid7vXHbtkGE67J8OhSAg9QHf8h39kqJtJZmy3kfAIIKSxm6 48KgYM/2beDck1BkkXfPRneMA6rhjZUkdXFVVkbuvozVpELS/4bA7h7UEoP9VKrHYORZ RFYx1DoqrgJLn8M33tYKAmA6rkuP2Qjg+5Lk9p7MfXIpKN4eOEWDYDcBn8S3xC4qWuOX qUvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791477650; x=1792082450; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HXq065e6nI28MxLdaLNxE40ltfZ0a3n1jeYu75IbvbU=; b=uhJgRxz63eYg1OKTMHFZxii0CbSMrau0ikzQEvp7odbhv7PuX6dF4X/oWU51eeLoIv lfKYtFxfe0OQGjkck80+N49LENSIs8M1HHjQtV1TmPmfQu/bQvaNo4kG396P4ZvkzPse 2ATByC7aMcKzpJMFFfrI4rNJO73FNtFJTEbwHSS8XiLxBuR1vaYWH0LoIpGUYWnEvMDN 3J2YG/4raumWI9X75kNWh8UWMNSH10FY8STnrHqLooVGDC26vbpUiHjjKNq1OxRklz+P md96R4PJeIrPU/2XwEP3ziAzns62ehx1vQGXZLcfP9JNS1nJ6QOUDNfTQqXetUewodL5 INxA== X-Forwarded-Encrypted: i=1; AKwUvByAyiANJ9HswkpzflMXm2M6nmDw0nc4MnXYk+h0x67urukyaWZ5lJM42UPXagM3o+aYXB1vVO+w/tKMjyo=@vger.kernel.org X-Gm-Message-State: AFuF++m0b0fyBEozB/XMmL0D4srrSYl6K41bI7/HC3P0I2SNsYVNgLde Lhu54Zi4OgjQF70qyFwdjikPYraEK6UE9L0AxhZ2iQzPkPAQIF/QJOeq X-Gm-Gg: AYBFou2oELSDlcg3sqZUEWKiXrjHdPDAJw4MHXe9Rx+hd4PWD2jQKUo8EYy0i6Q/Bea Q8Mf201JsWlmjdWwEhgkHgGdoyFsIw9CM6hBa4i7KLunfcMbWhvQHxbuUztSuv7VGJfpvs2hRBO M6ogpJ579cQwaeFVYI7FN7Y4cUIbbyY/ozmLyhyk088HpJPIddnpGHpynBttSZN/fmx3zwAe3UM qi6oPaQNX3khidB93jcw+mdpXG0KOaYg64bHGCac4HYz+qf/KBlMCReqZD6ch/aq7ASNE8Caz4j ysW+k32VVE+ovTx7bya2dZJDdJSnNN/eC0fQTSVxJYuDTQd/c8pN9LtJbgR7EKVVbUfIM02sjJ2 KBiSVVTDUBOrVMVncIDxDpWlMjvUxVMwQwbnyKpVtkCmjjhXgWLsC2Fp+tEAkxHX4aajkbD5KAK 9abGRi5pT7XgrJBv/0awxlpgwJsC4TtWBqkJzukjXZcu2qiL0JqN47HHw6tLTzGmJjEXRFoHGKL I1LyqKi/n6sW7WNmYyggl78Bg3muklcOUjueQ== X-Received: by 2002:a05:6870:568b:b0:475:e0a7:9f2f with SMTP id 586e51a60fabf-4a2595b8b6cmr5129058fac.29.1791477650369; Thu, 08 Oct 2026 09:40:50 -0700 (PDT) Received: from localhost.localdomain ([14.116.239.36]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4a274ca5a26sm3560744fac.17.2026.10.08.09.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2026 09:40:48 -0700 (PDT) From: Henry Martin To: Allison Henderson , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Henry Martin , stable@vger.kernel.org Subject: [PATCH] rds: fix out-of-bounds conn_path walk in peer gen update Date: Fri, 9 Oct 2026 00:40:41 +0800 Message-ID: <20261008164041.961961-1-bsdhenrymartin@gmail.com> X-Mailer: git-send-email 2.43.7 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A connection on the IB transport (t_mp_capable unset) is allocated with exactly one rds_conn_path slot, yet the peer's genetic number update routine is hardcoded to walk RDS_MPATH_WORKERS entries whenever the peer announces a non-zero gen number that differs from the one we cached. Everything past the first entry lands on whatever happens to follow the single-slot array in the same slab slot group, and the loop then reads and modifies struct fields there (lock acquired, cp_next_tx_seq cleared, retransmit list inspected). A malicious peer can therefore force consecutive out-of-bounds writes into neighbouring kmalloc-512 objects (KASAN: "Write of size 4 in _raw_spin_lock_irqsave"). The allocation and the walk now agree on the same expression (trans->t_mp_capable ? RDS_MPATH_WORKERS : 1), so the loop can never outlive the array regardless of what the peer reports. This vulnerability was discovered by Tencent CodeBuddy Security. Cc: stable@vger.kernel.org Fixes: ba3d1f480c7a ("net/rds: size a connection's path set by the transport it ends up with") Signed-off-by: Henry Martin --- net/rds/recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/rds/recv.c +++ b/net/rds/recv.c @@ -144,7 +144,8 @@ if (peer_gen_num != 0) { if (conn->c_peer_gen_num != 0 && peer_gen_num != conn->c_peer_gen_num) { - for (i = 0; i < RDS_MPATH_WORKERS; i++) { + for (i = 0; i < (conn->c_trans->t_mp_capable ? + RDS_MPATH_WORKERS : 1); i++) { struct rds_conn_path *cp; cp = &conn->c_path[i]; -- 2.43.7