From: netdev-bot+sashiko@kernel.org
To: shubham@octane.security
Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
achender@kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
linux-kernel@vger.kernel.org, gio@octane.security,
tjdqudcks0424@naver.com
Subject: Re: [PATCH net v3] net/rds: ib: zero the unwritten tail of a short receive fragment
Date: Mon, 12 Oct 2026 13:29:34 +0000 [thread overview]
Message-ID: <179181177407.434549.13953919662725859235@kernel.org> (raw)
In-Reply-To: <20261008124940.13371-1-shubham@octane.security>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch closes the info leak, but its v3 approach rests on a
false premise, and the commit message leaves out what the new memset…
--
net/rds: ib: zero the unwritten tail of a short receive fragment
This patch zeroes the unwritten tail of an RDS/IB receive fragment page in
rds_ib_process_recv() when the received payload is shorter than
RDS_FRAG_SIZE. The goal is to stop rds_ib_inc_copy_to_user() from copying
stale page contents to userspace when a peer sends a fragment shorter than
its h_len implies.
Closes: https://lore.kernel.org/netdev/20261006205204.1322102-1-tjdqudcks0424@naver.com/
> diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
> index bd6cb3ffaa571..9695c7f24eaa7 100644
> --- a/net/rds/ib_recv.c
> +++ b/net/rds/ib_recv.c
[ ... ]
> @@ -949,6 +950,19 @@ static void rds_ib_process_recv(struct rds_connection *conn,
> }
> }
>
> + /* The device wrote only data_len bytes into this recycled fragment
> + * page. Zero the unwritten tail so a later rds_ib_inc_copy_to_user(),
> + * which copies up to the peer-declared h_len, cannot hand stale page
> + * contents to userspace.
> + */
> + if (data_len < RDS_FRAG_SIZE) {
> + void *frag = kmap_local_page(sg_page(&recv->r_frag->f_sg));
> +
> + memset(frag + recv->r_frag->f_sg.offset + data_len, 0,
> + RDS_FRAG_SIZE - data_len);
> + kunmap_local(frag);
> + }
[Severity: Medium]
Isn't this condition true for the final fragment of almost every well-formed
message? A message whose h_len is not a multiple of RDS_FRAG_SIZE always
ends with a short fragment. So a 100 byte message now pays for a kmap and a
memset of roughly 4KB in the receive completion path.
For well-formed traffic that work doesn't look necessary, because
rds_ib_inc_copy_to_user() already stops at h_len:
net/rds/ib_recv.c:rds_ib_inc_copy_to_user() {
...
to_copy = min_t(unsigned long, to_copy, len - copied);
...
}
The stale tail can only be reached when a peer sends a short non-final
fragment, meaning data_len < min(RDS_FRAG_SIZE, ic->i_recv_data_rem).
The v3 changelog gives this reason for dropping the v2 length check:
A zero-copy send with a small iovec segment can legitimately produce a
non-final fragment shorter than RDS_FRAG_SIZE
Can that happen on RDS/IB? rds_sendmsg() rejects zero-copy on every
transport except TCP:
net/rds/send.c:rds_sendmsg() {
...
if (zcopy) {
if (rs->rs_transport->t_type != RDS_TRANS_TCP) {
ret = -EOPNOTSUPP;
goto out;
}
...
}
On the copy path, rds_message_copy_from_user() gets its sg entries from
rds_page_remainder_alloc(). Every entry it returns is a full PAGE_SIZE
except the last one. rds_ib_xmit() then splits each entry with:
len = min(RDS_FRAG_SIZE, sg_dma_len(scat) - rm->data.op_dmaoff);
That means only the last fragment of a message should ever be short.
Would it be better to bound the memset by
min(RDS_FRAG_SIZE, ic->i_recv_data_rem), which is already set at this
point? Rejecting that case as v2 did is another option. Either one should
still close the leak and leave well-formed traffic alone.
As written, a peer that sends short non-final fragments also gets its
message passed to the application with zero-filled holes, as if it were
valid.
The commit message also says:
Fragments that fill the page are unaffected.
In the common small-message case the final fragment doesn't fill the page.
Could the changelog say that the memset runs on most messages?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261008124940.13371-1-shubham%40octane.security
prev parent reply other threads:[~2026-10-12 13:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 12:49 [PATCH net v3] net/rds: ib: zero the unwritten tail of a short receive fragment Shubham Antil
2026-10-08 12:53 ` netdev-bot+sinfo
2026-10-11 7:05 ` Allison Henderson
2026-10-12 13:29 ` netdev-bot+sashiko [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=179181177407.434549.13953919662725859235@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=achender@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gio@octane.security \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shubham@octane.security \
--cc=tjdqudcks0424@naver.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