Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Fang Xieyan
Thu, 12 Nov 2026 12:51
[PATCH net 2/5] net: wwan: iosm: validate the ADGH datagram length
Author: Fang Xieyan
Date: Thu, 12 Nov 2026 12:51
Date: Thu, 12 Nov 2026 12:51
43 lines
10417 bytes
10417 bytes
ipc_mux_dl_adgh_decode() takes adgh->length from the device and hands
adgh_len - packet_offset to the network stack as the payload size of the
cloned skb, without bounding adgh_len at all. When the device reports a
datagram shorter than the ADGH header plus its negotiated padding, the
subtraction wraps to a huge u32, skb_trim() refuses the length and keeps
the clone unchanged, and the stack gets every byte left in the block
instead of the declared payload. A length beyond skb->len is nonsense
that the driver passes on as well.
Require the datagram length to cover packet_offset and to fit into
skb->len, and drop the block otherwise.
Fixes: c34ca4f32c24 ("net: wwan: iosm: fix incorrect skb length")
Cc: stable@vger.kernel.org
Reviewed-by: Guanglei Zhu <zhugl3@xiaopeng.com>
Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>
---
drivers/net/wwan/iosm/iosm_ipc_mux_codec.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
index 5c33171ca701..b573067a366f 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) {
+ dev_err(ipc_mux->dev, "invalid ADGH length %u, skb len %u",
+ adgh_len, skb->len);
+ return;
+ }
+
/* Pass the packet to the netif layer */
rc = ipc_mux_net_receive(ipc_mux, if_id, wwan, packet_offset,
adgh->service_class, skb,
--
2.50.1
Re: [PATCH net 2/5] net: wwan: iosm: validate the ADGH datagram length
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:55
Date: Mon, 16 Nov 2026 13:55
82 lines
10759 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads