Article View: linux.kernel.netdev
Article #16773Re: [PATCH net] net/rds: tcp: bound the message length announced by the peer
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 20:39
Date: Sun, 15 Nov 2026 20:39
134 lines
13094 bytes
13094 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · 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] After the new check in rds_tcp_data_recv() fires, the receive
path stops consuming data altogether, and this breaks the drain loop…
Pre-existing issues:
- [High] The patch does not cover the RDS IB/RDMA receive path, which has
the same flaw it fixes for TCP: the peer-announced h_len is never…
--
net/rds: tcp: bound the message length announced by the peer
This patch adds a check to rds_tcp_data_recv(). Once the header is
complete, the h_len announced by the peer is compared against
RDS_MAX_MSG_SIZE. If it is larger, the connection path is dropped and the
receive actor returns with -EPROTO.
> diff --git a/net/rds/tcp_recv.c b/net/rds/tcp_recv.c
> index ffe843ca219c7..29db73df84fa3 100644
> --- a/net/rds/tcp_recv.c
> +++ b/net/rds/tcp_recv.c
> @@ -213,6 +213,20 @@ static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
> }
> }
>
> + /*
> + * 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. Check on every pass, not only when the
> + * header completes: the drop is asynchronous and more data
> + * can arrive before the connection is shut down.
> + */
> + if (!tc->t_tinc_hdr_rem &&
> + tc->t_tinc_data_rem > RDS_MAX_MSG_SIZE) {
> + rds_conn_path_drop(cp, false);
> + desc->error = -EPROTO;
> + goto out;
> + }
[Severity: Medium]
After this check fires, tc->t_tinc is still set, with t_tinc_hdr_rem == 0
and t_tinc_data_rem > RDS_MAX_MSG_SIZE. Won't every later call into
rds_tcp_data_recv() hit the same check straight away and return 0 without
consuming anything?
__tcp_read_sock() stops on a 0 return:
used = recv_actor(desc, skb, offset, len);
if (used <= 0) {
if (!copied)
copied = used;
break;
}
So any payload after the oversized header stays on sk_receive_queue.
The drain loop in rds_tcp_conn_path_shutdown() only exits early when that
queue is empty:
rds_tcp_recv_path(cp);
} while (!wait_event_timeout(tc->t_recv_done_waitq,
(sk->sk_state == TCP_CLOSING ||
...
sk->sk_state == TCP_CLOSE) &&
skb_queue_empty_lockless(&sk->sk_receive_queue),
msecs_to_jiffies(100)) &&
++rounds < 50);
tc->t_tinc is only reset after this loop. Does that mean the loop now
always runs the full 50 x 100ms (about 5 seconds), even when the peer
answers our FIN promptly?
Each round goes through this chain and calls rds_conn_path_drop() again:
rds_tcp_recv_path()->rds_tcp_read_sock()->tcp_read_sock()->rds_tcp_data_recv()
That call does atomic_set(&cp->cp_state, RDS_CONN_ERROR) while the path is
in RDS_CONN_DISCONNECTING, and it re-queues cp_down_w. The
DISCONNECTING->DOWN transition in rds_conn_shutdown() then fails and
returns early. Is a second full shutdown pass forced before the reconnect?
This holds up the path's ordered workqueue, or the shared rds_wq if
alloc_ordered_workqueue() failed, and it delays reconnect. It would also
apply to every reconnect cycle of the old-kernel peers that the changelog
says will now be dropped.
Would it work better to consume and discard the rest of the stream once
the protocol error is detected, by returning the full len without cloning?
The drain loop could then finish, and the drop would not be repeated.
[Severity: High]
This isn't a bug introduced by this patch, but the IB transport appears to
have the same unbounded h_len problem. In net/rds/ib_recv.c,
rds_ib_process_recv() does:
memcpy(hdr, ihdr, sizeof(*hdr));
ic->i_recv_data_rem = be32_to_cpu(hdr->h_len);
There is no RDS_MAX_MSG_SIZE check. Each fragment is then kept until
i_recv_data_rem reaches 0:
list_add_tail(&recv->r_frag->f_item, &ibinc->ii_frags);
Continuation fragments are only checked for a matching header and a
minimum length. rds_ib_refill_one_frag() allocates a replacement frag for
each one consumed, with no limit.
The rds_ib_sysctl_max_recv_allocation cap in rds_ib_refill_one_inc()
counts rds_ib_incoming structures. A single huge message uses only one of
those.
Can an IB/RoCE peer that sends h_len = 0xffffffff, followed by full-sized
fragments, make the receiver hold up to about 4 GiB per connection?
rds.h describes RDS_MAX_MSG_SIZE as the limit for "both RDMA and non-RDMA
RDS message". Should rds_ib_process_recv() get an equivalent check,
followed by rds_ib_conn_error()?
Since this is tagged for stable, would it also help for the changelog to
say that only the TCP receive path is bounded?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111-h047-send-v1-1-2727a38dbfcd%40illinois.edu
Technical Details
Message-ID:
<179477516170.3136.3481236029450144068@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363849-linux-kernel-netdev=dewy.ruReferences:
<20261111-h047-send-v1-1-2727a38dbfcd@illinois.edu>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363849-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/rds: tcp: bound the message length announced by the peer Date: Sun, 15 Nov 2026 20:39:21 +0000 Organization: Usenet Network Message-ID: <179477516170.3136.3481236029450144068@kernel.org> References: <20261111-h047-send-v1-1-2727a38dbfcd@illinois.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1894901"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:O/53hRr1g+t1OrpjJEXpXUVu6fs= sha256:BSC0xcCp4s4rvjYGaa8L9yCVCUPnXj8N6LJHSAilYGE= sha1:XRmyQx7++p4JOO7fZa1OxgxRJEE= sha256:NNf9ZGC93Wrr5WUtXHDJvNpbIZEDQYPYampne1YN01I= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 4DF7C114A66; Sun, 15 Nov 2026 23:40:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9ivAVxCVItWK; Sun, 15 Nov 2026 23:39:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363849-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 702381144D3; Sun, 15 Nov 2026 23:39:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 498993533C; Sun, 15 Nov 2026 20:39:30 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794775169; b=2G90D76uC2Ibl+FfFK6qsoPTrYCJx5ifUFK4laGZw+PhUU28MVpIWO8+yXjAt8oOWZDd uyygqoKfkdgiVOETchJb7uhYEQwY/XL8tXnR7c7PQ21arAEZeIKTDUyb+s3EXGLznuqcA 2vVLIc8oX2e8A3coY3mNmYm4x+iCC9RyMNdaZvluZ3hbRzsTm80HJntNIwNLj1t3fEsdm 9eGJIEh/zf91uiCEtoVh1SrabLe+LQWe60GV+FIb7giyS/gsU4HkmGnIEamCDCDu5vVs0 Zv0kKEaqpdaAND9NMSKep2JbQKenR4BIrLpUDOzxfFq8ZnTyoMrpxjpO4vlxabaG9Vg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794775169; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=aGe6G0xKdhfQY0JtnV5P5L35DOTPKkJKnFisezZeybM=; b=vDoD0KYyaBuvu8OHyP9BAuBo/+KcX8Yk+tO8mYE4YXQcncO+lMvoadaqjuw03EQls9Hr 2l6YhTN9p/8bbe6YR/WfpPBQOJlQ4pHGVfvMJoPUn9pRkwGBEq5mGDAL1jiwfiSZQLo6L IFiRt1zfLMMRGsFp+/LniebHtEnjdFcKMK7t0jrjUaQ0VJrXZPeOZB5Y8c49vqBiYKXtE 1R2tlZpQ7s3TvHlDYIU3Rx0hfCAm3Okl3b7pZIvm/mVN7JvJGpCa0Q1jPmyR3YXIcJN1l jz7VASI4phl0CylWuxfmlG+IIq3Kzzox7DkuLcCJcR80qhcbhg21Vv0PiotLDjd4Vww== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B6f9qJgm; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E12B606A31F; Sun, 15 Nov 2026 20:39:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B6f9qJgm X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794775163; b=oamEbQDWxSImzWD+yPpcU4OsggrjV3VhB4OmW97PQgPtyxyBugcGAcWlbFUfeXsoS+oO RNF2acXrJsjbRdqSzrwm+mXB0g9T9EKZ0fIFd76Uqxf5W/+txfDbuqZRbQr9BBrZlVQlz fNiKJuhBqQrATDPlNdolMFXyMIqUBC5XBkae0n5wZX10V6mSFwzfYz0yKE4+W5WaaTusM ReWgavVN9+3qxuuAnefq3rVFLfWx13MfWbUj+JT+sWhvYmmKYDSWc/UWwEbDcU8rVpBwW unQrogIcKbzT6gWeSno690B5gv2hVU3SOO2bbIQapc5jftjE876u941CDB/DSAncn8Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794775163; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=aGe6G0xKdhfQY0JtnV5P5L35DOTPKkJKnFisezZeybM=; b=Xd6ouLz6MZb/Ln1l+SM68QG7T4UfW9Ip7oBilsGiIbBJSzboMpKQO4MqXHBij527WszM ZK3pbBDcmbvuyVDpNMaYILualCojltFlvnqJT1NqXp0buoC3BwLkZftpqLBvTcAWzZrAN F2bPdU+jQSUjgFf2LfoSrdxIxpHnmyifq+6/QKFBJXxxzizJND8r6/zwzjLS+uNq83kG6 xOlE/9o5RMX87WeHy4FXv58qSJH+u9zasCSJByc+fNWIReK9S5VJuM72TyI8EE2jHoSDE noroy9blJdxG+X3/1tw9UTsoKQNqizPhp8NFAXhsYbuk4L2cgnPM6gwzN7rnDJjpNcw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B6f9qJgm; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CACD606A323; Sun, 15 Nov 2026 20:39:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 264021F000C4; Sun, 15 Nov 2026 20:39:22 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794775162; bh=aGe6G0xKdhfQY0JtnV5P5L35DOTPKkJKnFisezZeybM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=B6f9qJgm/CcFJIUl3lq6ZZARB7LEAnB7sbDNpc641VS6e5nH21oGU+oXBr6lonRZ6 Y1XvCOS0ETx7UkID+yiB2Xl1n7s8td0+tzETfSNtS3SqFxez+jnaxtBWJfGIvn7SD3 A50zMMmq3fvwebmJMLmc9ZHmjipqN+jFePnTlUfbgfp8bF+bMaQmiVqvx3ujgD1To0 XbcXAQCmqc4N3eiIUcN07T0QMkXjAJt0bpAuZufZX/TNXLt53/q4rGNgXIQQoci1F+ IQ+3zE3L0uWcylFggbjMx8xtz0eOQzBUlbnrNViW7pvgEzHRcMNzjFDMF6LPtxjrqJ wnOjcskm8UV3Q== X-Cc: achender@kernel.org, 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 X-In-Reply-To: <20261111-h047-send-v1-1-2727a38dbfcd@illinois.edu> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list