Re: [PATCH net 2/5] net: wwan: iosm: validate the ADGH datagram length
From: netdev-bot+sashiko
Date: Mon Nov 16 2026 - 08:57:52 EST
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