From: Hidayathulla Khan I <hidayath@linux.ibm.com>
To: Bryam Vargas <hexlabsecurity@proton.me>,
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: Mon, 3 Aug 2026 11:58:14 +0530 [thread overview]
Message-ID: <d861388f-0a03-4994-9470-534f4cf4f14c@linux.ibm.com> (raw)
In-Reply-To: <20260723230647.138311-1-hexlabsecurity@proton.me>
Hi Bryam,
I have a standalone net-next patch that aborts the connection when
bytes_to_rcv + diff_prod exceeds rmb_desc->len. The check sits before
the atomic_add(), so the accumulator is never written with an out-of-range
value:
if (atomic_read(&conn->bytes_to_rcv) + diff_prod >
conn->rmb_desc->len) {
smc_cdc_abort_conn(smc, NULL);
return;
}
smp_mb__before_atomic();
atomic_add(diff_prod, &conn->bytes_to_rcv);
The patch also moves the open-coded abort sequence in
smc_cdc_msg_validate() into a new smc_cdc_abort_conn() helper, which
the overflow check above then reuses.
It is currently in internal review. I will post it to netdev shortly.
Thanks,
Hidayath
On 24/07/26 4:36 am, Bryam Vargas wrote:
> 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
>
>
prev parent reply other threads:[~2026-08-03 6:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 17:07 Ibrahim Hashimov
2026-07-22 3:47 ` Dust Li
2026-07-22 10:29 ` Ibrahim Hashimov
2026-07-23 23:06 ` Bryam Vargas
2026-07-24 7:21 ` Ibrahim Hashimov
2026-08-03 6:28 ` Hidayathulla Khan I [this message]
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=d861388f-0a03-4994-9470-534f4cf4f14c@linux.ibm.com \
--to=hidayath@linux.ibm.com \
--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=hexlabsecurity@proton.me \
--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
all inboxes | Powered by JetHome®