Re: [PATCH net v4 5/5] net: wwan: iosm: validate the command parameter length

From: netdev-bot+sashiko

Date: Wed Nov 25 2026 - 09:47:22 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The new parameter-length check never uses the device-supplied
cmdh->cmd_len, which is what delimits a command in this wire format.

--

net: wwan: iosm: validate the command parameter length

This patch passes a parameter length to the iosm MUX command decoders.
Each decoder checks it against the parameter union member its command
type uses and returns -EMSGSIZE when the member does not fit. The length
comes from skb->len for MUX Lite, and from next_cmd_index or skb->len for
commands in an aggregated command block.

> diff --git a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> index 3f93d72937858..b2bd53c5ba30f 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c

[ ... ]

> @@ -315,18 +329,26 @@ static int ipc_mux_dl_cmds_decode_process(struct iosm_mux *ipc_mux,
> static void ipc_mux_dl_cmd_decode(struct iosm_mux *ipc_mux, struct sk_buff *skb)
> {
> struct mux_lite_cmdh *cmdh = (struct mux_lite_cmdh *)skb->data;
> + size_t hdr_len = offsetof(struct mux_lite_cmdh, param);
> + size_t param_len = skb->len > hdr_len ? skb->len - hdr_len : 0;

[Severity: Medium]
Should param_len also be limited by cmdh->cmd_len here?

The kernel-doc for struct mux_lite_cmdh defines cmd_len as the length of
the command:

* @cmd_len: Length (in bytes) of the command. This length shall
* include the header size. Minimum value: 0x10

The encoders, ipc_mux_lite_add_cmd() and ipc_mux_acb_add_cmd(), also set
it to the header plus the parameter size, and skb_put() exactly that
much:

cmdh->cmd_len = cpu_to_le16(offsetof(struct mux_lite_cmdh, param) +
param_size);
...
skb_put(acb->skb, le16_to_cpu(cmdh->cmd_len));

Take an OPEN_SESSION_RESP that arrives with cmd_len = hdr_len + 4, so it
carries only the response code, with more bytes after it in the received
buffer. Would it still pass the new check in
ipc_mux_dl_cmdresps_decode_process()?

if (param_len < sizeof(param->open_session_resp))
return -EMSGSIZE;

/* Resume the control application. */
acb->got_param.open_session_resp = param->open_session_resp;

The reads now stay within skb->len. But the bytes after the command would
still be copied into acb->got_param. Then complete(&ipc_mux->channel->ul_sem)
would wake ipc_mux_session_open(), which uses those bytes as the response
and as ul_head_pad_len. A short FLOW_CTL would also have its mask read
from bytes beyond cmd_len.

ipc_mux_dl_acb_decode() seems to have the same gap. Each aggregated
command's extent comes from next_cmd_index or skb->len, not from its own
cmd_len:

cmd_end = next_cmd_index ? next_cmd_index : skb->len;
param_len = cmd_end - cmd_index - hdr_len;

So padding before the next command counts as parameter. For the last
command, the rest of the skb does too.

The commit message names this case as the bug being fixed:

"a truncated OPEN_SESSION_RESP copies bytes past the command into
acb->got_param"

It also says:

"cmd_len is passed to the decoder unchanged."

Would bounding the length by something like min(param_len, cmd_len -
hdr_len), when cmd_len >= hdr_len, be needed to cover the truncated
command case completely?

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121141850.73754-1-fangxy%40xiaopeng.com