From: sashiko-bot@kernel.org
To: "Bryam Vargas" <hexlabsecurity@proton.me>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
linux-rdma@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH net v6 1/3] net/smc: bound the wire-controlled producer cursor to the RMB
Date: Fri, 09 Oct 2026 06:12:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-164917@kernel.org> (raw)
In-Reply-To: <20261008-b4-disp-f7cd3d96-v6-1-fba616c0920c@proton.me>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] smc: NULL pointer deref in smcr_cdc_msg_to_host() via token guessing race
--
commit 841c4fb2c2d0123708a65170d68d2745b02a7ce8
Author: Bryam Vargas <hexlabsecurity@proton.me>
net/smc: bound the wire-controlled producer cursor to the RMB
This commit bounds the wire-controlled producer cursor to the receive
buffer length in smcr_cdc_msg_to_host() and smcd_cdc_msg_to_host(). This
prevents a peer from advertising a producer cursor past the buffer bounds
and disclosing adjacent kernel memory during urgent data path processing.
> diff --git a/net/smc/smc_cdc.h b/net/smc/smc_cdc.h
> --- a/net/smc/smc_cdc.h
> +++ b/net/smc/smc_cdc.h
[ ... ]
> @@ -246,8 +256,13 @@ static inline void smcr_cdc_msg_to_host(struct smc_host_cdc_msg *local,
> local->len = peer->len;
> local->seqno = ntohs(peer->seqno);
> local->token = ntohl(peer->token);
> - smc_cdc_cursor_to_host(&local->prod, &peer->prod, conn);
> - smc_cdc_cursor_to_host(&local->cons, &peer->cons, conn);
> + /* bound the wire-controlled producer cursor to our RMB (used as a raw
> + * index by the urgent path); leave the consumer cursor unbounded -- it
> + * indexes the peer's RMB and is bounded by peer_rmbe_size.
> + */
> + smc_cdc_cursor_to_host(&local->prod, &peer->prod, conn,
> + conn->rmb_desc->len);
[Severity: High]
Can this lead to a NULL pointer dereference?
There appears to be a race window where conn->rmb_desc can be NULL when this
code is executed. In af_smc.c, smc_connect_rdma() registers the connection
via smc_conn_create() before the send buffer and RMB are created via
smc_buf_create():
af_smc.c:smc_connect_rdma() {
...
reason_code = smc_conn_create(smc, ini);
...
if (smc_buf_create(smc, false)) {
...
}
During smc_conn_create(), smc_lgr_register_conn() is called, which makes the
connection globally visible with a highly predictable token:
smc_core.c:smc_lgr_register_conn() {
...
while (!conn->alert_token_local) {
conn->alert_token_local = atomic_inc_return(&nexttoken);
if (smc_lgr_find_conn(conn->alert_token_local, conn->lgr))
conn->alert_token_local = 0;
}
smc_lgr_add_alert_token(conn);
...
}
If an unauthenticated remote peer on the same RoCE network guesses the token
and sends a CDC message over the active link before smc_buf_create() allocates
the rmb_desc, smc_cdc_rx_handler() will process the message and call
smcr_cdc_msg_to_host(). This would cause a kernel panic when trying to access
conn->rmb_desc->len.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261008-b4-disp-f7cd3d96-v6-0-fba616c0920c@proton.me?part=1
next prev parent reply other threads:[~2026-10-09 6:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 6:12 [PATCH net v6 0/3] net/smc: bound wire-controlled CDC cursors against the local buffers Bryam Vargas via B4 Relay
2026-10-08 6:12 ` [PATCH net v6 1/3] net/smc: bound the wire-controlled producer cursor to the RMB Bryam Vargas via B4 Relay
2026-10-09 6:12 ` sashiko-bot [this message]
2026-10-09 6:41 ` netdev-bot+sashiko
2026-10-08 6:12 ` [PATCH net v6 2/3] net/smc: bound the receive length to the RMB in smc_rx_recvmsg() Bryam Vargas via B4 Relay
2026-10-09 6:12 ` sashiko-bot
2026-10-09 6:41 ` netdev-bot+sashiko
2026-10-08 6:12 ` [PATCH net v6 3/3] net/smc: bound the send length to the send buffer in smc_tx_sendmsg() Bryam Vargas via B4 Relay
2026-10-09 6:12 ` sashiko-bot
2026-10-09 6:41 ` netdev-bot+sashiko
2026-10-08 6:15 ` [PATCH net v6 0/3] net/smc: bound wire-controlled CDC cursors against the local buffers netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-164917@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hexlabsecurity@proton.me \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox