Thread View: linux.kernel.netdev
6 messages
6 total messages
Started by Andrew Stellman
Sat, 28 Nov 2026 19:17
[PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit
Author: Andrew Stellman
Date: Sat, 28 Nov 2026 19:17
Date: Sat, 28 Nov 2026 19:17
58 lines
13495 bytes
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
Re: [PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit
Author: Dust Li
Date: Mon, 30 Nov 2026 02:22
Date: Mon, 30 Nov 2026 02:22
48 lines
10749 bytes
10749 bytes
On 2026-11-28 14:17:30, Andrew Stellman wrote:
>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.
How did you force the connection to 508? Connections in a link group
are supposed to be limited to 255. Did you modified the kernel?
If this comes from a malicious/non-compliant peer bypassing the 255
limit, we should look closely at the receive path.
Best regards,
Dust
Re: [PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit
Author: Andrew Stellman
Date: Mon, 30 Nov 2026 13:15
Date: Mon, 30 Nov 2026 13:15
24 lines
12538 bytes
12538 bytes
On Mon, Nov 30, 2026 at 10:22:21AM +0800, Dust Li wrote: > How did you force the connection to 508? Connections in a link group > are supposed to be limited to 255. Did you modified the kernel? > > If this comes from a malicious/non-compliant peer bypassing the 255 > limit, we should look closely at the receive path. Yes, I modified the kernel for that test. A test-only change set the count to 508 inside smc_llc_fill_ext_v2() and reused one real RMB for the extra entries, so it shows what the writer does with that count. It wasn't 508 real connections, and no peer sent anything unusual. From reading the code, the 255 limit is only enforced for the server role. smc_conn_create() skips the max_conns and rtoken bitmap check for a client link group, and smc_rtoken_add() reuses a slot when the peer repeats an RMB rkey and address. I haven't actually run a case where a peer gets a client link group past 255, though, so I can't say for sure it's reachable. If you'd rather fix this on the receive side or when the connection is created, I'm happy to rework the patch that way. Andrew
Re: [PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit
Author: Mahanta Jambigi
Date: Tue, 01 Dec 2026 09:15
Date: Tue, 01 Dec 2026 09:15
78 lines
15863 bytes
15863 bytes
On 29/11/26 12:47 am, Andrew Stellman wrote:
> 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
The overflow mechanism is right, but I think the missing bound belongs
one layer up: the client link group is the only one that can grow past
255, because smc_conn_create() exempts that role from the limit it
applies to the server:
(role == SMC_CLNT || ini->is_smcd ||
(lgr->conns_num < lgr->max_conns && ...))
Would dropping role == SMC_CLNT be the *better fix*? A conforming peer
never notices: max_conns is the negotiated minimum, so the server moves
to a new link group, with a new QPN(Queue Pair Number), before the
client's limit is reached, and smcr_lgr_match() then no longer matches
the old group. For a peer that keeps the QPN, smc_conn_create() already
returns SMC_CLC_DECL_SYNCERR when the client cannot join the group the
server reused, so the connection is declined instead of growing the
group. That bounds conns_num at 255, which is what keeps the rkey list
inside the work-request buffer.
> 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);
Re: [PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit
Author: Andrew Stellman
Date: Tue, 01 Dec 2026 21:31
Date: Tue, 01 Dec 2026 21:31
22 lines
12448 bytes
12448 bytes
On Tue, Dec 01, 2026 at 02:45:27PM +0530, Mahanta Jambigi wrote: > Would dropping role == SMC_CLNT be the *better fix*? I tried it. On mainline (fe6ff8d5d675) in arm64 QEMU with KASAN, lockdep and SoftRoCE, I opened 260 SMC-R connections from one client to one server, held them, and then closed them. Without any patch, both runs closed cleanly. With role == SMC_CLNT dropped, the client hung in close() in both runs. The stacks show a link-group termination worker waiting in smc_cdc_wait_pend_tx_wr() while close() waits for the same socket lock in smc_release(). With 64 connections, both builds closed cleanly. I haven't found why the CDC completion never comes, and I haven't run a peer that reuses its QPN. Dust, as I said before, the 508 count came from a test-only change inside the writer, not from real connections. Given that, would you rather keep the cap in smc_llc_fill_ext_v2() as sent, or should I keep looking into the hang with the client bound? Andrew
Re: [PATCH net] net/smc: cap ADD LINK v2 rkeys to the receive limit
Author: Dust Li
Date: Wed, 02 Dec 2026 01:31
Date: Wed, 02 Dec 2026 01:31
33 lines
10139 bytes
10139 bytes
On 2026-12-01 16:31:55, Andrew Stellman wrote: >On Tue, Dec 01, 2026 at 02:45:27PM +0530, Mahanta Jambigi wrote: >> Would dropping role == SMC_CLNT be the *better fix*? > >I tried it. On mainline (fe6ff8d5d675) in arm64 QEMU with KASAN, >lockdep and SoftRoCE, I opened 260 SMC-R connections from one client to >one server, held them, and then closed them. > >Without any patch, both runs closed cleanly. With role == SMC_CLNT >dropped, the client hung in close() in both runs. The stacks show a >link-group termination worker waiting in smc_cdc_wait_pend_tx_wr() >while close() waits for the same socket lock in smc_release(). With 64 >connections, both builds closed cleanly. > >I haven't found why the CDC completion never comes, and I haven't run a >peer that reuses its QPN. Dust, as I said before, the 508 count came >from a test-only change inside the writer, not from real connections. > >Given that, would you rather keep the cap in smc_llc_fill_ext_v2() as >sent, or should I keep looking into the hang with the client bound? IIUC, that looks like a potential issue that can never be triggered in the current Linux code? If so, I don't think it's necessary to add the bound here. I think it makes more sense to focus on reachable issues first, such as a client violating the protocol and sending invalid CLC messages to the server. Best regards, Dust
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads