🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18023

[PATCH net v2 0/5] net: wwan: iosm: validate MUX DL lengths and offsets

#18023
From: Fang Xieyan
Date: Tue, 17 Nov 2026 17:39
83 lines
12623 bytes
The MUX downlink decoders trust several modem supplied lengths and
offsets without bounding them against what actually arrived: the block
size from the transfer descriptor, the ADGH datagram length, the ACBH
block length, the command chain offsets and the declared parameter
length. A truncated or enlarged DL block makes the driver read past the
received data, hand the network stack an undeclared payload, or walk a
command chain that loops or redecodes the same bytes. The aggregated
datagram block path is already covered by commit 526b8ef54668 ("net:
wwan: iosm: bound device offsets in the MUX downlink decoder") and is
not touched here.

This series adds those bounds. No command type, response or protocol
semantics change, so a conforming modem behaves exactly as before. A
parameter too short for the member its command type reads is dropped
with -EMSGSIZE, which also ends an aggregated block at that command.
Patch 4 is the prep change for patch 5; both carry Cc: stable, as patch
5 cannot be backported without patch 4.

cmd_len is not a parameter bound in either path. In an aggregated block
the boundary is next_cmd_index, or the end of the received block for the
last command. In MUX Lite there is one command per skb, so the received
length is already everything that command owns; the flow control decoder
treats a mismatching cmd_len as a legacy device, so the field is a
compatibility flag, not a length bound.

Patch 3 bounds the ACBH command chain by the received length rather
than block_length. Although the structure describes block_length as
the length of the aggregated command block, the uplink encoder
initializes it to the ACBH header size and does not update it as
commands are appended, so it cannot delimit the received command
chain. The field is sanity checked, while first_cmd_index and
next_cmd_index are bounded against skb->len. The walk's
array_index_nospec() call is removed: it bounded a byte offset by
sizeof(struct mux_cmdh), zeroing every legal offset past that size.
The offset indexes no array; array_index_nospec() is kept only for
if_id, an actual array index.

Patch 2 relies on the ADGH header check from patch 1, patch 5 on the
ACBH validation from patch 3 and the parameter pointer from patch 4.
Every commit applies and builds individually, W=1 drivers/net/wwan/iosm/
is clean. Found by reviewing the DL decode path against the MUX protocol
structures, not reproduced on a live modem: reaching it needs a device
that truncates or enlarges its own downlink blocks. The series is based
on the net tree at 145480b28ca8.

Changes in v2, all three points from the Sashiko AI review of v1:

- Patch 5 bounds the MUX Lite parameter by the received length alone,
  not by cmd_len: v1 dropped legacy FLOW_CTL (cmd_len 16..19) and
  OPEN_SESSION_RESP (16..27) even when the parameter bytes had arrived,
  defeating the backward compatibility branch in
  ipc_mux_dl_cmds_decode_process() that exists for exactly these (the
  protocol minimum for cmd_len is 0x10).

- Patch 2 rejects adgh_len == packet_offset too: the zero length clone
  reached ipc_wwan_receive(), which reads skb->data[0] without checking
  skb->len. mux_dl_process_dg() already rejects the same case for the
  aggregated path with dl_head_pad_len >= dg_len.

- Patch 4 gains Fixes: 9413491e20e1 and Cc: stable@vger.kernel.org: its
  by-value signature copied all twelve union bytes even for a four byte
  response, and patch 5 bounds the session responses, so the two are
  needed together. A prerequisite itself marked for stable and present
  in the series need not be listed, per stable-kernel-rules.rst.

Patch 1 is unchanged. Patch 3 changes only its changelog and comments.

v1:
https://lore.kernel.org/netdev/20261112125201.1019-1-fangxy@xiaopeng.com/

Fang Xieyan (5):
  net: wwan: iosm: validate the MUX DL block length
  net: wwan: iosm: validate the ADGH datagram length
  net: wwan: iosm: bound the ACBH command chain walk
  net: wwan: iosm: pass the DL command parameter by pointer
  net: wwan: iosm: validate the command parameter length

 drivers/net/wwan/iosm/iosm_ipc_mux_codec.c | 187 ++++++++++++++++-----
 1 file changed, 141 insertions(+), 46 deletions(-)

-- 
2.50.1
Technical Details
Message-ID: <20261117173940.34970-1-fangxy@xiaopeng.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365506-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365506-linux-kernel-netdev=dewy.ru
From: fangxy@xiaopeng.com (Fang Xieyan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 0/5] net: wwan: iosm: validate MUX DL lengths and offsets
Date: Wed, 18 Nov 2026 01:39:35 +0800
Organization: Usenet Network
Message-ID: <20261117173940.34970-1-fangxy@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2390897"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Wg/pHacEWuByTitvoC9A7LG6Yws= sha256:lr0YC+pfIrbikqhjfPwLN7XV/k2lqnAT5H4JRMTCpbI=
	sha1:SHjJCV49ECkbAStORrxd4heZRr0= sha256:8sE7qpPNk7IoLeGd1H2O2miEbfTOjW08cEObTKgo4sk=
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 0CF0511501E; Tue, 17 Nov 2026 20:40:50 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=xiaopeng.com
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 nqbOd7nGB216;
	Tue, 17 Nov 2026 20:40:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-365506-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id BE367115011; Tue, 17 Nov 2026 20:40:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 9D3D860E869; Tue, 17 Nov 2026 17:40:34 +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=1794937232;
	b=2K+tEYlYEs5TYU3wq1gmJJ3dPKQd0fViTaeK0S0DLTS7232z4ZOt1gBV4Tp0YSv3R+Dd
	 ms9R2p3AiIf0pUDzWt4w2lgebWOS4yQA3TFjYRM7bNJFl+yrbsgNFdRCXH1C8oUzd+QMC
	 aohXVBL8Bb5rBWuLSJD/aoOXkAMEQTfHU2ioRX8r/9yQ2l7LuZ5+VY23eiymqv72w2im/
	 Dm0+pRVYutooy5po8IVY1eSW7/fSPXrhpI0/iwojZ8ziylB2ugTaZSUE9KdvEc1dWcGoj
	 jr6BQU11HPzkjzZoVyTtxvmGONo8HWvXuZ78HeuikJc1kl4rsp2bobSt7X0BOpNMofw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794937232;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=NfnXEPcZubGYIvAuu0emS2kkZCekEVtpp7Kmyvr+j48=;
	b=xozebtl5rcIOQRUyRixXYzfDhY6Qg3iOSunlFN3cP1lXksGLYUA9NPzosfLzu2kNmjZT
	 /9QP6ZReBxp56iluy95EsR/ymm6esRHx+pfiIX/P93fW8jMzGC1K/dcvX8GBrKXryXpKK
	 1WEuUOKySobsjn+KFV5l0sSHfeOHyuoQ9Llq9tXh/7LVoEH5HHnNzv1eqhaQpRFah148n
	 tp/sz4EPlZMRsRqviyjEfw++214R0pQlP1hyWU+85rCtvru6XQPMe5L8N1p3hFA5K59Ih
	 cJXY+FrbTsXsLJLzrKMzDamoR4+tN9uBoTHjmXRd5aL4Hc7HFx3Et1wCZu4htwWR2ng==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=Pw+yyWHv;
	dmarc=none header.from=xiaopeng.com;
	spf=pass smtp.mailfrom=xiaopeng.com;
	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 E7D34606A337;
	Tue, 17 Nov 2026 17:40:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=Pw+yyWHv
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.219
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794937231;
	b=EyQcXh26BEhYKIBFygerWHtg6Q6KrTsYtI5iAnu2oTmIcVuB5wDaHIfozbIuYBDkjNYT
	 jL+E0TnpXH4HEgvb+OQ610lCKsViPO3jgR280fpelkPsFXUojHessgjNnzDwoaSWN8q9g
	 V1VdXAyf9NrJ2LoAfPbKFOsz8tV7miCv3Tzo4R2Vpk+UcHf9hc04ASZj3ZrawGntr1jcY
	 79UYqRbLpPYP+QAgtpLNdw6/BqUVn5Y1HHUU25P7g40K/bPhu7Y2Tm8k8FDQhRBs+1263
	 DCUJSAQPEyBRZpUBQqexDit79JF0iSsSPvFVuKVqkATCPmpuLSLqutg5JeuzB3noCmw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794937231;
	h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=NfnXEPcZubGYIvAuu0emS2kkZCekEVtpp7Kmyvr+j48=;
	b=a/jv3er4Qeb4Wxyt26dFrkJjU9hy77aJwwINDRtCxeTM+Es8zbrl4j070JlCeaXSIvzy
	 s9YuNyrRa6/QiHql6StZdO9Xx+QIwWP7FTX1Q4irc954E1y2/LgC7M/+efQ+2XhyTVXy1
	 PKvs2EWr97mVdN2otfxbg6c4J5PeH6HRHoBaB9i+HW+OkRQGZie01tXhVOrjWUo2mNMq7
	 XZlOBrsypBGqaRW53Z42Yg+hVi93H89/oiI2EG5TUBbr1vdwvr1v8gui5wetptsZNVpbH
	 XDLuEQ2OMmvJOAhYDQlVgkcHbSBoEs3Y82eLMc5HZqVCA+gxO2Ooa+EuRfSsxG8Qk5g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=xiaopeng.com;
	spf=pass smtp.mailfrom=xiaopeng.com;
	dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=Pw+yyWHv;
	arc=none smtp.remote-ip=115.124.28.219
X-Received: from out28-219.mail.aliyun.com (out28-219.mail.aliyun.com [115.124.28.219])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05F9E606A31C;
	Tue, 17 Nov 2026 17:40:28 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 05F9E606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=xiaopeng.com; s=default;
	t=1794937221; h=From:To:Subject:Date:Message-ID:MIME-Version;
	bh=NfnXEPcZubGYIvAuu0emS2kkZCekEVtpp7Kmyvr+j48=;
	b=Pw+yyWHvhW7avJpMHYmnES9fKDVVdWdnAg/3X3sCk1ifTNIm12LpGR5tzyS9ScIaSYXyz0uabrS+x2sw0F9cQQ3oUmk8DAigKs6PJrMYMyxrsng2vAap0X0XHWveuJG3HhVX6LBzuFjnz6SqD6vLE89LIGqqnvBpiWpCuRQbs1g=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.04475058|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0078416-0.000222638-0.991936;FP=12416432432656457696|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033045099153;MF=fangxy@xiaopeng.com;NM=1;PH=DS;RN=12;RT=12;SR=0;TI=SMTPD_---.k4BATDp_1794937219;
X-Received: from localhost.localdomain(mailfrom:fangxy@xiaopeng.com fp:SMTPD_---.k4BATDp_1794937219 cluster:ay29)
          by smtp.aliyun-inc.com;
          Wed, 18 Nov 2026 01:40:20 +0800
X-Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Simon Horman <horms@kernel.org>,
	Johannes Berg <johannes@sipsolutions.net>,
	Maoyi Xie <maoyixie.tju@gmail.com>,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.50.1
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