From: Bryam Vargas <hexlabsecurity@proton.me>
To: Ibrahim Hashimov <security@auditcode.ai>,
Dust Li <dust.li@linux.alibaba.com>,
Wenjia Zhang <wenjia@linux.ibm.com>,
"D. Wythe" <alibuda@linux.alibaba.com>,
Sidraya Jayagond <sidraya@linux.ibm.com>,
Tony Lu <tonylu@linux.alibaba.com>,
Wen Gu <guwen@linux.alibaba.com>,
Mahanta Jambigi <mjambigi@linux.ibm.com>
Cc: Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
"David S. Miller" <davem@davemloft.net>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-s390@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net/smc: validate peer CDC cursor against RMBE size before accepting it
Date: Thu, 23 Jul 2026 23:06:56 +0000 [thread overview]
Message-ID: <20260723230647.138311-1-hexlabsecurity@proton.me> (raw)
In-Reply-To: <20260722102929.38218-1-security@auditcode.ai>
Agreed, and thanks for dropping the competing one.
Patch 1/3 bounds only the cursor count, not the advance: smc_curs_diff()'s
differing-wrap branch returns (len - old.count) + new.count, so prod(W,0) then
prod(W+1,len) is diff_prod == 2*len with both counts in range, and
smc_cdc_msg_recv_action() adds that to bytes_to_rcv unclamped. wrap++/count==0 does the
same over several CDCs, so a per-cursor bound can't catch it.
The out-of-bounds copy you point at is closed by patch 2/3, though. It bounds the
derived readable length at the consumer:
if (readable < 0 || readable > conn->rmb_desc->len)
readable = conn->rmb_desc->len;
so copylen <= rmb_desc->len and smc_rx_recvmsg()'s second chunk (copylen - first,
offset 0) stays within the ring no matter how large bytes_to_rcv grew. I ran your
wrap++/count=0 vector end to end on the real SMC-D path under KASAN: with 1/3 alone it
trips slab-out-of-bounds in smc_rx_recvmsg (bytes_to_rcv reaches 6*len, read of size
5*len); with 2/3 applied recv() is bounded to rmb_desc->len and it is clean.
What 2/3 does not fix is the accounting: bytes_to_rcv is left > rmb_desc->len (and can
sign-overflow negative over many messages), so the documented
0 <= bytes_to_rcv <= rmb_desc->len invariant is still violated at the producer even
though the copy is now bounded. I have a net-next follow-up that records and aborts on
that. Your
if (smc_curs_diff(size, &old, &temp) > size)
return;
catches the single-CDC 2*len advance cleanly; the wrap++/count==0 form slips it, since
each CDC advances exactly len (diff == len, not > len) and it is the accumulated
bytes_to_rcv that overruns. So I'll pair your advance-bound as an early catch with a
check on bytes_to_rcv after the atomic_add and abort+record there, which covers both.
The insight is yours either way -- may I add your Suggested-by (or Co-developed-by)?
The v4 series otherwise stands as reviewed; I'll repost it for the netdev queue and
keep the accounting bound as the net-next follow-up.
Thanks,
Bryam
next prev parent reply other threads:[~2026-07-23 23:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 17:07 [PATCH net] net/smc: validate peer CDC cursor against RMBE size before accepting it Ibrahim Hashimov
2026-07-21 17:08 ` sashiko-bot
2026-07-22 3:47 ` Dust Li
2026-07-22 10:29 ` Ibrahim Hashimov
2026-07-23 23:06 ` Bryam Vargas [this message]
2026-07-24 7:21 ` Ibrahim Hashimov
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=20260723230647.138311-1-hexlabsecurity@proton.me \
--to=hexlabsecurity@proton.me \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@google.com \
--cc=guwen@linux.alibaba.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjambigi@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=security@auditcode.ai \
--cc=sidraya@linux.ibm.com \
--cc=tonylu@linux.alibaba.com \
--cc=wenjia@linux.ibm.com \
/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