๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17229

Re: [PATCH net 2/5] net: wwan: iosm: validate the ADGH datagram length

#17229
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:55
82 lines
10759 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The new ADGH length check in ipc_mux_dl_adgh_decode() is
  `adgh_len < packet_offset || adgh_len > skb->len`.

--

net: wwan: iosm: validate the ADGH datagram length

This patch adds a bounds check on the device-supplied adgh->length in
ipc_mux_dl_adgh_decode(). The block is dropped unless the length covers
packet_offset and fits within skb->len. Without the check, a short length
wraps the payload size computed as adgh_len - packet_offset.

> diff --git a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> index 5c33171ca7012..b573067a366f0 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> @@ -473,6 +473,15 @@ static void ipc_mux_dl_adgh_decode(struct iosm_mux *ipc_mux,
>  	if_id += ipc_mux->wwan_q_offset;
>  	adgh_len = le16_to_cpu(adgh->length);
>  
> +	/* The device supplied length bounds the datagram. It has to
> +	 * cover packet_offset and fit into the received block.
> +	 */
> +	if (adgh_len < packet_offset || adgh_len > skb->len) {

[Severity: Low]
Should the lower bound be adgh_len <= packet_offset?

With the strict comparison, adgh_len == packet_offset still passes. That
gives a datagram with no payload, and ipc_mux_net_receive() is called with
pkt_len == 0.

For example, the modem could send a 16-byte ADGH block with
adgh->length == 16. dl_head_pad_len is IPC_MEM_DL_ETH_OFFSET, so pad_len
is 0 and packet_offset is 16. ipc_mux_net_receive() then does:

	skb_pull(dest_skb, offset);
	skb_trim(dest_skb, pkt_len);

and the clone reaches ipc_wwan_receive() with len 0. That function reads
the first byte without checking skb->len:

drivers/net/wwan/iosm/iosm_ipc_wwan.c:ipc_wwan_receive() {
    ...
	if ((skb->data[0] & IOSM_IP_TYPE_MASK) == IOSM_IP_TYPE_IPV4)
		skb->protocol = htons(ETH_P_IP);
    ...
}

So skb->protocol comes from a stale byte past the datagram. The empty frame
is also counted in rx_packets/rx_bytes and passed to netif_rx(). The read
stays inside the DL buffer allocation, so this is not a memory safety
problem.

The aggregated path for the same protocol, mux_dl_process_dg(), already
rejects this case:

		if (dg_index >= le32_to_cpu(adbh->block_length) ||
		    dg_index >= skb->len ||
		    dg_len > skb->len - dg_index ||
		    dl_head_pad_len >= dg_len) {
			goto dg_error;

Would using <= here make the ADGH and ADB decoders agree?

> +		dev_err(ipc_mux->dev, "invalid ADGH length %u, skb len %u",
> +			adgh_len, skb->len);
> +		return;
> +	}
> +

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112125201.1019-1-fangxy%40xiaopeng.com
Technical Details
Message-ID: <179483731765.3136.9756237680420915159@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364399-linux-kernel-netdev=dewy.ru
References: <20261112125201.1019-3-fangxy@xiaopeng.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364399-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/5] net: wwan: iosm: validate the ADGH datagram length
Date: Mon, 16 Nov 2026 13:55:17 +0000
Organization: Usenet Network
Message-ID: <179483731765.3136.9756237680420915159@kernel.org>
References: <20261112125201.1019-3-fangxy@xiaopeng.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2079656"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:OBs7+eh5HWU3dTU/hzlefKDdMF0= sha256:w75zo0eTMs7tCCHPK3LpwGs3+UajnyvB7EMcBEkiJ+c=
	sha1:g9sIrrsv+NlJZsD04sz0Qb4X6bc= sha256:kPsqdcSCSO4rDEFKxraD+4MP5VnEFqabMnhglTGXHh4=
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 D5801114C5A; Mon, 16 Nov 2026 16:57:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[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 k0NrOnxI2xPC;
	Mon, 16 Nov 2026 16:57:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364399-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 92098114C42; Mon, 16 Nov 2026 16:57:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 39F4632B81; Mon, 16 Nov 2026 13:56:52 +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=1794837320;
	b=gi5DISztSPoXXC6SFDqrnqSUYiN5eD7R9eRaN2FPeGse6YXX6ejRJsXmUWeJ07KUxr4x
	 Rj5CzZHfRLwRmGpLucKsCjaY1+oNCQONGGPDKqNRqi/LofmplesPBiSD3RrWtzBCxJcib
	 RoP/Ig5HnRst0l/GHZg2WjtGTdlElAwBwxWxRfRbiHuQfhP+YTAYqnKdJUPkZOVOSFpYU
	 ziFSLhX/Am1WFfK65DSXe3gLzZ1FcyqK1v7YA/Mv/JDHCT3lXXezmUf1/tYgftzm3Co0T
	 s1o48Ad4tcHFi6K/tCLc6gohu8/NObLxmLiNLa+G14Nxr/MNNPOOCuC8bz58XOUC2FQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794837320;
	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=L+9EA2+eiAIQrNgICkfUh6aQq6fKl8y/LGKwTRK2g8Y=;
	b=Cj6aeRyBVJmvPjfnYGaaJiUK1OUkajEImERzVp8dyfEBv/zct3XpefWMAC4Z+jJg+Pkl
	 4owYpAcKFAySY9VKXrsNdJsJr0xI5fXNFHL8w+0YDA1+voft4OnfJ+7NqU+dIyW6HQ4mB
	 lYYEJAYz18pRI9ZIif0jgBq7cckEEske9kfrEk59ROgWmZs7jLrMI1ULO/AT0pFtlQ+4A
	 JfPvJNSX3HhWkfg2V1gRkS9OE/+F+vDKChY3nlP0yzl5w4kE08V3+0dhnZkK0Hjm1pmTZ
	 4b993uyNgpgkpsG2sjXT1EZ54B8Tl23oeiRVRxm4zL26qojppeSd0/8aW+AiUCt9yEA==
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=luQh3eZS;
	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 35A26606A893;
	Mon, 16 Nov 2026 13:55:20 +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=luQh3eZS
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=1794837319;
	b=hkpiaDq+2oExV4dggVJ48zKAdEmuHYt4lrsG0O/tM6gfNyjaElmFVg+rxU7upt/lAfGQ
	 FvJnImxJ68dfvHb27clGBjZJI+3XCWj9pos+jOYJ/XmB8X/V+Th5YN4GqY4yEDeikKScN
	 kLfUc+GV6q/5WbfwgJ+wwvol+2NGzoV7tbmQpJxJdMxO4oVsZQs8mGnjYHMmHQPuIZEom
	 XY/rjegPEnmbej3tm4duw1PsoQ3SZsEREqVCmd9j1UhVpTJnPMhASaHY4HifFr9KpY1k+
	 eM0jKUQvrGuIqN0DFe8ECc+8qpjPvUJmVTV4xgP3VGQzmvJqP5s2Js/CE7Z+k4pCYlg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794837319;
	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=L+9EA2+eiAIQrNgICkfUh6aQq6fKl8y/LGKwTRK2g8Y=;
	b=I8xo6+Flrxa4Fci5eiJyYz6PJYz83SdZQsrZDrlL4EhnCcjMrxNjTADvnYJ7Z2YyRU3u
	 8RfPMpojDEqWlTYCCbW4ePuPaddxkiirYtPlGg2TiJUWmL1aNqni/knYEbOO0jn9n0KWL
	 WxvO9fhAAbU2MEpG0X+XoWnnTrpFrjPx373OaDBoiF6qUGHApfl73cv+SNinetOYp5J+f
	 k5paiLZ2r1qU92F5b46IM3PeZpZAdu8rxanFmpcX6AH2pJhU8rTkNeVExkbN5xKpeOngQ
	 tLrhpidltsrzxnObzoWTTxI5mo+nMnMMsRLbdyZqWnfsSeKyeYDdUr8h28j3c3JTeQg==
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=luQh3eZS;
	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 5662D606E72E;
	Mon, 16 Nov 2026 13:55:19 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 287281F000CA;
	Mon, 16 Nov 2026 13:55:18 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794837319;
	bh=L+9EA2+eiAIQrNgICkfUh6aQq6fKl8y/LGKwTRK2g8Y=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=luQh3eZStg6L5kTLYQtdUiWeK/gIbvcGOjR7QCrznusr3YYJ06mI+Ae+P5CL53BJJ
	 zhL1Z2qw6TLOtJFnIwNn7LHmDiOnT9f0D3eN649YR7bKQNcTPaY6BIrL5/i4enAylY
	 lupvbPlKFlcq9amOGzE52qtGBmE1+8lmajNg4TjG5HLGif6to9eHUMGhAP+2J0STwU
	 bng60Y9cT7Ng1dr1V/U2afHOuCNWfpLdlICwjZbnao2MeUiujj42T8LA3HPk6Y9szW
	 KAm3MmHY2u2YxONIGzLMB8+tm6RbH+9QnRplfpmbmJg4C1c3SOd/+tkUZ1VsdBjgrC
	 /tSxREALVcXug==
X-Cc: loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com,
 netdev@vger.kernel.org, johannes@sipsolutions.net, andrew+netdev@lunn.ch,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 linux-kernel@vger.kernel.org, maoyixie.tju@gmail.com, horms@kernel.org,
 m.chetan.kumar@linux.intel.com, zhugl3@xiaopeng.com
X-In-Reply-To: <20261112125201.1019-3-fangxy@xiaopeng.com>
X-sashiko-severity: Low
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