Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: weidongw@illinois.edu
Cc: achender@kernel.org, andy.grover@oracle.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	zijie4@illinois.edu
Subject: Re: [PATCH net v2] net/rds: tcp: bound the message length announced by the peer
Date: Fri, 27 Nov 2026 03:40:37 +0000	[thread overview]
Message-ID: <179575083740.3135.167711549334185146@kernel.org> (raw)
In-Reply-To: <20261125-h047-send-v2-1-b29031cf6b93@illinois.edu>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · 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).

- [High] The new check in rds_tcp_data_recv() (net/rds/tcp_recv.c:219-220
  and 230-234) limits the number of payload bytes a peer can announce…

--

net/rds: tcp: bound the message length announced by the peer

This patch limits the h_len announced in an incoming RDS/TCP header to
RDS_MAX_MSG_SIZE in rds_tcp_data_recv(). If a header is larger, the
connection is dropped. The rest of the stream is then consumed and
discarded until shutdown, so the receive queue keeps draining.

> diff --git a/net/rds/tcp_recv.c b/net/rds/tcp_recv.c
> index ffe843ca219c7..4ca25b9d25d40 100644
> --- a/net/rds/tcp_recv.c
> +++ b/net/rds/tcp_recv.c
> @@ -210,9 +210,29 @@ static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
>  					be32_to_cpu(tinc->ti_inc.i_hdr.h_len);
>  				tinc->ti_inc.i_rx_lat_trace[RDS_MSG_RX_START] =
>  					local_clock();
> +				/*
> +				 * The payload is queued on tinc until the
> +				 * whole message has arrived, so a peer must
> +				 * not announce more than a sender is allowed
> +				 * to send.
> +				 */
> +				if (tc->t_tinc_data_rem > RDS_MAX_MSG_SIZE)
> +					rds_conn_path_drop(cp, false);

[Severity: High]

Does this check bound the memory held for a partially received message,
or only the announced length?

A peer can announce h_len = RDS_MAX_MSG_SIZE, which passes this check.
It can then send the payload as roughly one million 1-byte segments.
Each segment goes through:

rds_tcp_data_ready()
  rds_tcp_read_sock(cp, GFP_ATOMIC)
    tcp_read_sock()
      rds_tcp_data_recv()
        pskb_extract()

Each one ends up as its own clone on tinc->ti_skb_list, further down in
rds_tcp_data_recv():

	clone = pskb_extract(skb, offset, to_copy, arg->gfp);
	...
	skb_queue_tail(&tinc->ti_skb_list, clone);

pskb_extract() calls skb_clone(). The clone has no sk and no destructor,
so nothing is charged to the socket.

It then calls pskb_carve(). For linear data, pskb_carve_inside_header()
allocates a new head of skb_end_offset(skb) bytes with kmalloc_reserve().
For nonlinear data, pskb_carve_inside_nonlinear() also takes
skb_frag_ref() on the rx page frags. Either way, the allocation does not
depend on how few bytes are extracted.

rds_tcp_data_ready() drains sk_receive_queue on every data_ready. That
means tcp_try_coalesce() never has a tail skb to merge small segments
into, so every segment becomes a separate clone.

Wouldn't that leave on the order of 1M uncharged clones per connection
path? Each has an sk_buff plus a new head or pinned page, so the total
is roughly 1 GiB or more, and the receive window stays open.

rds_recv_incoming() later charges only h_len to rs_rcv_bytes, so the
actual truesize is never accounted.

The commit message describes the problem as the receiver holding large
amounts of memory that is not charged to the socket. To close that
fully, could this bound the total truesize on ti_skb_list, or copy or
coalesce small chunks, rather than only check h_len?

>  			}
>  		}
>  
> +		/*
> +		 * After an oversized header the connection is being dropped:
> +		 * consume and discard the rest of the stream until it is shut
> +		 * down, so that the receive queue drains and the shutdown is
> +		 * not held up.
> +		 */
> +		if (!tc->t_tinc_hdr_rem &&
> +		    tc->t_tinc_data_rem > RDS_MAX_MSG_SIZE) {
> +			left = 0;
> +			break;
> +		}
> +
>  		if (left && tc->t_tinc_data_rem) {
>  			to_copy = min(tc->t_tinc_data_rem, left);
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-h047-send-v2-1-b29031cf6b93%40illinois.edu

      parent reply	other threads:[~2026-11-27  3:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  3:40 [PATCH net v2] net/rds: tcp: bound the message length announced by the peer Weidong Wang via B4 Relay
2026-11-26  3:44 ` sashiko-bot
2026-11-27  3:40 ` 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=179575083740.3135.167711549334185146@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=achender@kernel.org \
    --cc=andy.grover@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --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=rds-devel@oss.oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=weidongw@illinois.edu \
    --cc=zijie4@illinois.edu \
    /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