From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795893453; b=p94EM78ZCM8OL7kyowkK7MIrA/w1iSE1FlDMcT5apX2gQOW20nA+hTqMZt3Pjvf/c3Ur HmyIdtgfq44cxp8Ed3/Xug70ftEuZ0+oTzl2F7pdUyTVctQP83vZGSDX9OZZp8SOC68Yi rsomBEPs2HCAKE+UuW0fArmjAGGpvUvzU8uisWUZCG5Gb2RPlsWths7GtaO+A1IntAp4/ NfA89M/uv465CI52+u4rxJpap/O6Z1PR0MMl17eWQGo0h7x9SZXOEvOI+ePW/p+6TMSzM lYoJBeRhc3YXacH1zDvpQxKiUs/EekpcVugUr3MWVgR17D6utLPP9rYG+H5P94iyN9Q== 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=iRsmEmla0HicJL7nJ1SPUbSZ5Ps62egk1SBRqZpRE7Gy0l19d9RbRGg09fwj9quEHE8t 3fNglHOJrzaOhDLyyYQhxq6o6CGmM0NRIC1VZUBWoFKdTXRnD5JRhhToQ7ddq3GsLI24W 6/H0mSbyJbrTWwdjyd2jFy2tz0AWrk3Hb92pwsBEZ2bMpSAijA/5tCYDI41iLwSPIsUBt OrRPvqi95UvZ0CQazT8tg1aFQmeFOaQsL3FYKEJXRoJGqOFylsyTZN9zo6gzUnx5N4Ewy 3up64NjNGuHjOgyngFPLH2XoUhV300VzPezHruGnYmmgetnhwpZf2OD6aRuSVb2kbHg== 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.181 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 A8539606A32A for ; Sat, 28 Nov 2026 19:17:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8539606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stellman-greene.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=stellman-greene.com 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 Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-5363316fa0cso95781591cf.3 for ; Sat, 28 Nov 2026 11:17:32 -0800 (PST) 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=JfI85Ab8YSrbHp2p61ZBFeN60i8THpDndrkKYe+nJNwnBRqfPrDqQQETEmTcOXyU2Z YdWgW3zNeQ1LmcU8rEQyy8gLzhMzZa0kWoqRr+QTlasIDYAdL64dIxV1aAU4kMiE//zL afaeKFJI+jJnnwJ0jIl96Qtlno9EoaOHrq6558ICPBgm4qrF14gGXbjhkE/lXgBMwGmY h3EJTBszTD7aRK5cj5HkhJiK3ynQVNY4BwcpQJ7W1D2kHzbiMD1E4LZS9Drr52yqxQLV 3aafLLlubfDM0U+2+QrD384nSwZwdu77XLSP5WfY7ulFxSr0l3jEvxltXrcxRptC1V/k LGwQ== X-Forwarded-Encrypted: i=1; AL+hErGs+uG9dC+UqVUqbK5IYO6Ws381te7LFmRRyVSjfLOdagepA5OomMSCnPyKNO0wHxhgwkHrPhtkrFvM@vger.kernel.org X-Gm-Message-State: APuU4Z+SC7zud9/lh9zGVuR3TMw674sXXdOU/NhZ6iTPyant27YYgpdw e6wbgyEA6W0grwA7y0SL3zGm0aW9U9NVj3+SuAFk71hoK44/f1unDbnPVflLvseCTjw= X-Gm-Gg: AZFdTZc+XySwaAsTJL+PhiVMeEzWoR6nM+4SR2eXv0FMNFIrB8j/CjVyvTneOS3or3+ wSFzKoDXlO7x7au2Ul6xRkyGD2/288RYUY90HeoUtEKGlLm+W7SP1/XCIkrF8pvj7/vOlWUQ4ih 7FWIAEGGWPDyutGMTQrFJQrAivUFGDx/CUBh8DZktjbiopbTmBBaf0kORjaUg+1IoQXqvm8xfve UzE7k42TrDcldFCuarTw4we1CWYgLiYfEHitPjqOeLZbXdzSCeKSx0WbCk/xotqwqjazKmy5Yr7 O3pIXapJ1bP21SyeqGqoiYSqN0qdTzZW4wDsf7E5rh2WCEopsvnMuSkzJk8Fe1WlNnBfXw4jynG yqsLEkrpNb0S4AYMturE5EXkehp9Jqk9AFo2O7AgtAm7pVsHBIMYbNvIlOh0J44yokhBPfmqB6R 5W2YpCunN5OdH1j/aX53GfDkVqYBUN8puSiN+wAwOR0RNqMG1E7xIPPJjLBV6IJOWNW/lHwhyhb LhUExrN8o3/7BVdToxC9wUYNJM+QP+MgWS75hYZ8iP2kx35xWpskrPiNASJt+sOY3biUQOUmaAR A0vJJEYnsyLsZoFEgFNT+pwg4o/SfbCi3OgcXiKm7lmWKnKvvQHgCAE+y2PmnhUNq7IEwO/Izzc nsA== 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) 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) From: Andrew Stellman To: "D. Wythe" , Dust Li , Sidraya Jayagond , Mahanta Jambigi Cc: Tony Lu , Wen Gu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Willem de Bruijn , linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit Date: Sat, 28 Nov 2026 14:17:30 -0500 Message-ID: <20261128191730.30196-1-bugs@stellman-greene.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Andrew Stellman 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 --- 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