🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23975

[PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit

#23975
From: Andrew Stellman
Date: Sat, 28 Nov 2026 19:17
58 lines
13495 bytes
From: Andrew Stellman <astellman@stellman-greene.com>

smc_llc_fill_ext_v2() writes one 16-byte rkey entry per connection in
the link group into the 8192-byte SMC-Rv2 work-request buffer. The
count is lgr->conns_num and has no upper bound. After the headers there
is room for 507 entries, so a count of 508 writes eight bytes past the
buffer.

smc_conn_create() checks max_conns and the rtoken bitmap only for the
server role, and smc_rtoken_add() reuses an rtoken slot when the peer
repeats an RMB rkey and address, so a client link group isn't limited
to 255 connections. I didn't run a case where a peer brought a link
group to 508 connections.

Cap the count at SMC_LLC_RKEYS_PER_MSG_V2 (255), the limit that
smc_llc_save_add_link_rkeys() applies on receive. This changes existing
behaviour: in a group with more than 255 connections, ADD LINK now
carries only the first 255 rkeys, and later connections get no rkey on
the new link.

Tested on mainline (7.4.0-rc4) in arm64 QEMU with KASAN and SoftRoCE.
A test-only change forced a count of 508 and reused one RMB for the
extra entries, and KASAN reported an 8-byte out-of-bounds write. With
this patch there was no report, and reverting only the cap brought it
back. A two-connection SMC-R run with only this patch applied gave no
KASAN report.

The issue was found by Claude Opus 5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
Claude Opus 5.5, and both were reviewed by me.

Fixes: b4ba4652b3f8 ("net/smc: extend LLC layer for SMC-Rv2")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
A reproducer is available on request.

 net/smc/smc_llc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c
index c9ccd8480369ca..9f6ba5f75b8f2b 100644
--- a/net/smc/smc_llc.c
+++ b/net/smc/smc_llc.c
@@ -638,7 +638,8 @@ static int smc_llc_fill_ext_v2(struct smc_llc_msg_add_link_v2_ext *ext,
 	prim_lnk_idx = link->link_idx;
 	lnk_idx = link_new->link_idx;
 	down_write(&lgr->rmbs_lock);
-	ext->num_rkeys = lgr->conns_num;
+	ext->num_rkeys = min_t(unsigned int, lgr->conns_num,
+			       SMC_LLC_RKEYS_PER_MSG_V2);
 	if (!ext->num_rkeys)
 		goto out;
 	buf_pos = smc_llc_get_first_rmb(lgr, &buf_lst);
-- 
2.53.0
Technical Details
Message-ID: <20261128191730.30196-1-bugs@stellman-greene.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373268-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373268-linux-kernel-netdev=dewy.ru
From: bugs@stellman-greene.com (Andrew Stellman)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit
Date: Sat, 28 Nov 2026 14:17:30 -0500
Organization: Usenet Network
Message-ID: <20261128191730.30196-1-bugs@stellman-greene.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1012830"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:K8dk/r5jiN9/MO4wQePdXyVHJ1s= sha256:lV3WBTgzQnlcE93QCEYT5EA0Au5yM2Psq2zNKYNeNRQ=
	sha1:X+BZtTxv8F7C6DYUnVPJte3i/rU= sha256:0A9ZrfFiD8QjqWRADQscModqRsB99rPdst+RqosBQ9Q=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id B30E8125F88; Sat, 28 Nov 2026 22:17:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=stellman-greene-com.20260707.gappssmtp.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id bD43QuRNVnIR;
	Sat, 28 Nov 2026 22:17:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373268-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=stellman-greene.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 8F7AA125F8B; Sat, 28 Nov 2026 22:17:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id B2092282EF; Sat, 28 Nov 2026 19:17:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795893454;
	b=OLs1LhOHFeKoh8ncYpDIoiFfjTDLhrfSQNZNbwZTubAFokrRckWqx5r2xf3GJdKCMu/y
	 gZOtUXGJJsOGzM8s3J0ciWm0IvZxqxxXzrh0BDxZZLCFtpEiy7RlofjWDlX9mAe8U63+j
	 24vHTrgOc5h7XBSKE8csr+7G8fC5G/XJRuBua34A90RO5xVA6OjInXJOoashp702w+q7A
	 uzDLILJnIwrkqz84OeBaBGaI0V4RBAt++g0eEVXZy8Z3h28E2SqCCW5aZoxrat8XzvJTi
	 YArV8hxIhAYGhXKgmTXHtyE/gUQz52dD+VmInSjBLa9xN5UYPTihwhN5W+YNU2MOFFg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795893454;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=h+OpZuk+FGZzrjWr47NJ4gZQ963s97nZQCxQhq1O2AY=;
	b=qnQZase3wLwycKDzRx+9OtTYoEJR5d1qzO9uMEgBDHnAtfsZYYOCjOMYq+wmrM5ukvHo
	 arH9BjMiwc1hg9rh/JEGsj+mDkMeWF1q9HsmMSg1SyWcKtGkDeKBmu6hluNXFAHHKyVKa
	 oiIqvKaHSO2Y2AFPmAVCLsQ7MHrvJO9aBhSB1htLCfvblC2LOo7WNtzuCyq/YNerkL4JJ
	 aNSArdKra+5xUnaTZaoHX1TmerovS4ZjJQe5plEx/oq4wLfXyZy/vMdR7vifMyKeYyvsJ
	 o2iVAzt9PKIeumVOFk2Kj62wkmAT45snPyBKodZ9dQAVXBPCvu21VJaW+yKBaD8CYZw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=AFJ5oKHu;
	dmarc=none header.from=stellman-greene.com;
	spf=none smtp.mailfrom=stellman-greene.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id E3F24606A324;
	Sat, 28 Nov 2026 19:17:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=AFJ5oKHu
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.173
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795893453;
	b=u0wxl8eM31BARICJgwQKzqd3IOPR/2R6eyq+Cd35GojCqck/ZlcpWFKwab/wXl1rFZ0V
	 8XrL4wnBmt9mFGnDv6NoTVLy6ER5iMc+y0Yq2ULG9JI5bBUXYoRb2P3zwDr3rdajJtmgg
	 Q+7Utv/HVRwpeBmhL+1HGhCNpXU+FRWvp1D/wk/PHT5tymN1ZBnTgiEBCOcxiFLo+nLyK
	 feBYgQZlN9Xcrc1oMIdn7+14UNksefyOAwvECFM7qOHQrY0j7sv+PzcFFD3VIJPFondmU
	 umJ3cXS+uHztFTNh7zmShYMHqqigKq04wLahvRaouqj4iTVRTM6ZSe/uhhazUwtRu3Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795893453;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=h+OpZuk+FGZzrjWr47NJ4gZQ963s97nZQCxQhq1O2AY=;
	b=Z4IXaZNUbBrZ86wiaAJJW9TTmIVVcHfNg/WehyhoEUj9o10Ib16oh+iIMPUtfQem/DQk
	 WVzkni63R1/O5UUVk7MLz6VEq8fB0kBX92KVqZZzf2G6zglyvRw0knD6XcJtgvv492c/Q
	 PV2BLII5lTF7+4miAXuo3gQ2YdyDrpm0zw3YiEVcz8jvPfVODd1EiWFrO9IXCz1AbAS0t
	 jSSlxIlasuF+Fo1/DKSzL5opAUYoinehPGuygUjAK/DtDq8/3yBcqOlbuQNJEZoPYg6l8
	 5Wfg7saC3/r2he4JDv5989JAp93mn9ehy47EdK4OJg9QLmRPzOC53Btix0jE965IpGA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=stellman-greene.com;
	spf=none smtp.mailfrom=stellman-greene.com;
	dkim=pass header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=AFJ5oKHu;
	arc=none smtp.remote-ip=209.85.160.173
X-Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB647606A32D
	for <netdev@vger.kernel.org>; Sat, 28 Nov 2026 19:17:32 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BB647606A32D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stellman-greene.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=stellman-greene.com
X-Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-5430f70c827so108054771cf.2
        for <netdev@vger.kernel.org>; Sat, 28 Nov 2026 11:17:32 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=stellman-greene-com.20260707.gappssmtp.com; s=20260707; t=1795893451; x=1796498251; 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=h+OpZuk+FGZzrjWr47NJ4gZQ963s97nZQCxQhq1O2AY=;
        b=AFJ5oKHusF5vvk5vu+no/sehvZCKlvIrqH7ZP2K0MMpvtA+M4cE2S+Vj+l8t7/IdxR
         5bG5zIOV6/Q5Gkq849/WPlyqRuihasm4O3ZPDuypd7Boan+h/NcFGU9zK7mtn+Ekie5V
         g32KHuOp1SBSVkEK9biiUGDlgz+DXcxGqe14UyDL71Ihv1bHYiPwXduIVPacbIV68iz7
         wwHAL2KlvQRM78YGpdwNe6KNT2zO6eXrRUWGjmRNJMDLWwoD2Na+X0QFbUy/IXWiNP+q
         +Ae4V3sRfz4VtxiA3cpCRwcQEIxZuDlvw8EaUZJzN70O/cjLUDvMOLfUP06esHrewzRM
         yXhg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795893451; x=1796498251;
        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=h+OpZuk+FGZzrjWr47NJ4gZQ963s97nZQCxQhq1O2AY=;
        b=NjZ/cA4R1TZAhPN/JLxFaDi4bgVZKOvwOAJFVHAbT0x8bXdVfcoEItga4lE87Zk4hb
         x/Zr7Lb48HaYOph0o5WZf+7dt7wqHA01K1pT03LNBCkWNT8TrRdvPA+VX2N/28hI1Bbt
         6FxKB5UggYujPBut4nJGRE7HvfJJFbLpS2KofBwF/pt1Oi1QtqPcEORFqPFIooxYg3kv
         SQFshCnViEVRa6nw2moYqjLK9QGIJyA8/OdGEZTa8vaTS12c/4wrh1WA/C6TkON/LpH0
         oMYk9XjkyLTaxOWubvZqtUhR4PP0QhEvmgRlE4obz3N7V1D73tW7CIk1tHMBgCqOvP88
         uuLQ==
X-Forwarded-Encrypted: i=1; AL+hErExOnevzQ6mGcsX/k9ShJHmtxFS3d9fEwkmhJ62uRqgMbocP6pKCy4j8dNijs6RsoSjL71TaX4=@vger.kernel.org
X-Gm-Message-State: APuU4Z9vqTmQXGVFjzGvKSfCiMllm4YvA8Gx6XiMCgwMxHPfZnfXsVU7
	/qECrzn3WzrBCW7Pk29HjS6Sa30SvrL9b3YRmJXSzCQoRnfSylUrd5VgGno5LO6FzCw=
X-Gm-Gg: AZFdTZdX2SdgkwDNJ8YjplA38DJFLAyusxvBT+G3Dp+SFeWIMwX+wx8NExvtQW5rAwP
	ffg+jzEaejG7IXU5PKC0oOf22yxczuW6IE1SC/lxyD+OoO94/sF77YtRMl1rQvY12PzXfFY+RIx
	pwLcUDA9d+l0J9MgqwPEy1g/+7U2vTm41QK8tAWXIUpOhL9rcTjJaj07tg6wki/thQi0dGJMGKb
	cT4erH3Ek7Yhi7GUfFdHJCK9wRETS7/OwofmxtNj0/84/4LTUbG+7VgWrpJkqIvo4oIOORtQtrT
	cAyczOOwtKmZ5vyh+L7Mnd9TJSXMWCULmiasQVOGTBRenMrcZNOAWUgYph654/Hp+NwlJ9PrT7U
	3vp4z1MVHmnowviTIT4H0LAGq86EnQhUMnt78SOir68wiCKAdpUkKp+ACAnfioBEneyMtOZWw28
	8u7zX8FBrM1pnEKhOEULylvbztEjLfPL06Gh/5KETCtN9hAs2i1Z07rrVUnVNX5RYGMUNex37vJ
	cD41MTZk/pUlcKisNDXFbEyQNgLauN37ZFJS3B3b4iJrJPzEOpoS5HogmqTriHQeuFVy3lowVEM
	bRLm1eB1bteiZU10ufw6ioQC0IdW94TkHhmVKHyRLMqy4k93xqNue5wWrTBS268nE0pZDCQJ/wc
	DRg==
X-Received: by 2002:a05:622a:2446:b0:54f:ba12:8496 with SMTP id d75a77b69052e-55d76a4a16amr483659121cf.46.1795893451625;
        Sat, 28 Nov 2026 11:17:31 -0800 (PST)
X-Received: from Mac.mynetworksettings.com ([2600:4041:5c28:200:a4e3:fb15:aef5:60c7])
        by smtp.gmail.com with ESMTPSA id d75a77b69052e-55d7884d01csm238698441cf.21.2026.11.28.11.17.30
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Sat, 28 Nov 2026 11:17:31 -0800 (PST)
X-Cc: Tony Lu <tonylu@linux.alibaba.com>,
	Wen Gu <guwen@linux.alibaba.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	linux-rdma@vger.kernel.org,
	linux-s390@vger.kernel.org,
	netdev@vger.kernel.org
X-Mailer: git-send-email 2.53.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list