🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #36

Re: [PATCH net] net/rds: ib: drop fragments shorter than the header-declared length

#36
From: Allison Henderson
Date: Wed, 07 Oct 2026 01:13
75 lines
8495 bytes
On Tue, 2026-10-06 at 18:27 +0530, Shubham Antil wrote:
> rds_ib_process_recv() accepts an incoming RDS/IB fragment once the
> receive completion reports at least an RDS header
> (data_len >= sizeof(struct rds_header)).  It then trusts the
> header-declared total message length h_len: for the first fragment of
> a message it stores be32_to_cpu(hdr->h_len) in ic->i_recv_data_rem,
> and rds_ib_inc_copy_to_user() later copies up to h_len bytes from the
> fragment pages to userspace on recvmsg().
> 
> The number of payload bytes actually received into the fragment page is
> data_len (after subtracting the header), but it is never checked against
> the amount the fragment is accounted to contribute to the message,
> min(i_recv_data_rem, RDS_FRAG_SIZE).  A fragment whose header advertises
> a larger h_len than the payload it delivers is still linked onto the
> reassembly list.  The fragment page comes from the per-CPU receive cache
> and is not zeroed, so rds_ib_inc_copy_to_user() then copies up to h_len
> bytes to the PF_RDS reader, including the uninitialized tail the receive
> never wrote.
> 
> Reject a fragment that carries fewer payload bytes than it is accounted
> to contribute before linking it onto the reassembly list.
> 
> The issue is reproducible under KMSAN with two hosts over rdma_rxe
> (Soft-RoCE); the same reproducer confirms the fix stops it.
> 
> Fixes: 1e23b3ee0e94 ("RDS/IB: Receive datagrams via IB")
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Shubham Antil <shubham@octane.security>

Hi Shubham,

Thanks for working on this.  This patch looks good to me, you can add my rvb:
Reviewed-by: Allison Henderson <achender@kernel.org>

Also, this bug was found and reported privately by another contributor, whom I had
counseled to send a patch publicly before I had noticed this one.  
https://lore.kernel.org/netdev/20261006205204.1322102-1-tjdqudcks0424@naver.com/

I find that patches equivalent, and this patch was posted first. But I would like to apply
the reported by tag since sungbyeongchan was the first to report it.
Reported-by: sungbyeongchan <tjdqudcks0424@naver.com>

Thank you both for working on this bug!
Allison

> ---
>  net/rds/ib_recv.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
> index bd6cb3ffa..fee77b6d7 100644
> --- a/net/rds/ib_recv.c
> +++ b/net/rds/ib_recv.c
> @@ -949,6 +949,15 @@ static void rds_ib_process_recv(struct rds_connection *conn,
>  		}
>  	}
>  
> +	/* h_len must be backed by the payload actually received (data_len),
> +	 * else the unwritten frag-page tail is copied to userspace.
> +	 */
> +	if (data_len < min_t(u32, ic->i_recv_data_rem, RDS_FRAG_SIZE)) {
> +		rds_ib_conn_error(conn,
> +			"fragment shorter than header-declared length; forcing reconnect\n");
> +		goto done;
> +	}
> +
>  	list_add_tail(&recv->r_frag->f_item, &ibinc->ii_frags);
>  	recv->r_frag = NULL;
>  
Technical Details
Message-ID: <661e8b900c97d701382af26462bead7277eaa41f.camel@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342155-linux-kernel-netdev=dewy.ru
References: <20261006125720.81227-1-shubham@octane.security>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342155-linux-kernel-netdev=dewy.ru
From: achender@kernel.org (Allison Henderson)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net/rds: ib: drop fragments shorter than the
 header-declared length
Date: Tue, 06 Oct 2026 18:13:29 -0700
Organization: Usenet Network
Message-ID: <661e8b900c97d701382af26462bead7277eaa41f.camel@kernel.org>
References: <20261006125720.81227-1-shubham@octane.security>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="550479"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8A1rfiRIDB2zix1Nikq1z4NBYLk= sha256:Rfuevns/vzP+GpwTcdGGdnuikTJla3wLMD9YBTjdpuA=
	sha1:OSltG5iD4H4D1Is/TWCY0BVxbe0= sha256:j24DJyVFV4QhBym5aqQt8dieGUc3XA9tUFPNDO1twr0=
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 988DF10F0B1; Wed,  7 Oct 2026 04:14:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.341
X-Spam-Status: No, score=-1.341 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, 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 ZJXy2e6APV8s;
	Wed,  7 Oct 2026 04:14:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-342155-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 40CCE10F0B0; Wed,  7 Oct 2026 04:13:58 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 7273030BEA; Wed,  7 Oct 2026 01:13:32 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id E6009334374;
	Wed,  7 Oct 2026 01:13:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WEtGnLJZ"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68CDE335564;
	Wed,  7 Oct 2026 01:13:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791335611; cv=none; b=gjXwIw2BKGvP3PLGXIqXllcKVlEUPl8TGtS3KNowEtIUcdXlkjnJqldS2lzCOCsxTOMCeAuWXRllx65dgbeJ3/UAUEt4gwUMJq+Cm+nTIPJMzqNSamwztcSUzPRrFGx7DvzceyQwTV26urLOBMaMXse7HxK9WG7TKBtPf/lNp/U=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791335611; c=relaxed/simple;
	bh=5LE030dETA5TkWeVQ5A61CyYEuK0E201J0RsXvWQn8o=;
	h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References:
	 Content-Type:MIME-Version; b=EvfSFyAiEI9B1OGtq2tfcBwckv71v9edeT2gdCN2yYbZlesLdIRGGG6kSzJbPJCCaoOIswcxGBfoLBmyNAxFsngc51O2pozxdphZkkoOA+r7EyGw1y/O6a3a0E+POIxoDUlmTm6YFXfE2EH5kHjgHjE4iQq1jBVcsNfpxPB2g7I=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WEtGnLJZ; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BC761F0089B;
	Wed,  7 Oct 2026 01:13:29 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1791335610;
	bh=sdBJccuOm1EfEsP5aXIPMxQG/B3g2rtoCS73T15p9Oo=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=WEtGnLJZgHikZ2uaLHyY1UOzilXTJQeuI0vuWhlc+rLUCsO3pE4IyUiSDuIGvy9Io
	 EYeM4rOs4wSyFmCXhbPsPHouJ3sGtX0GqQ/YcML+a16a9ESw9qjYWd1ewF9KbBDeqU
	 B/tnKhNnuiWgKTbkNBQMy1ZlNU7ouVhPx35rwYTZKfQmNjuvjXxAhsvwRFRxTdXcyv
	 6Mu3b2AW/G6MGlEx4sXCGpdLJ8rAspCTiWDPNtv3Ht69+RVBoRzZvQ3wHh5rTGjCeu
	 ot5J+Np0GAk2BxQS8G0iHnp7KanEYyFX+wk46/UIy3dWk1wPXzJM+0aTXhF/XKdiNr
	 b/6KAg6O+mz5w==
X-Cc: "David S . Miller" <davem@davemloft.net>, Eric Dumazet
 <edumazet@google.com>,  Jakub Kicinski <kuba@kernel.org>, Paolo Abeni
 <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
 linux-kernel@vger.kernel.org, Giovanni Vignone <gio@octane.security>
X-In-Reply-To: <20261006125720.81227-1-shubham@octane.security>
X-User-Agent: Evolution 3.52.3-0ubuntu1.1 
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>