Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: fangxy@xiaopeng.com
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
Subject: Re: [PATCH net 5/5] net: wwan: iosm: validate the command parameter length
Date: Mon, 16 Nov 2026 13:55:19 +0000	[thread overview]
Message-ID: <179483731920.3136.4345864455275657786@kernel.org> (raw)
In-Reply-To: <20261112125201.1019-6-fangxy@xiaopeng.com>

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

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

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] In ipc_mux_dl_cmd_decode() (MUX Lite path,
  drivers/net/wwan/iosm/iosm_ipc_mux_codec.c:338-345), once cmd_len >=…
- [Low] This commit is tagged 'Cc: stable@vger.kernel.org' (Fixes:
  9413491e20e1) but depends on the preceding series commit "net: wwan:…

--

net: wwan: iosm: validate the command parameter length

This patch works out a parameter length for each received DL command. For
MUX Lite it comes from cmd_len. For aggregated blocks it comes from
next_cmd_index, or from skb->len for the last command. The union member
each command type uses is checked against that length. A parameter that is
too short returns -EMSGSIZE, the callers drop the command, and in the
aggregated path the walk of the command chain stops.

> diff --git a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> index aea4cd9ec20d3..bd6c82746cc4a 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> @@ -185,6 +185,7 @@ void ipc_mux_netif_tx_flowctrl(struct mux_session *session, int idx, bool on)
>  
>  static int ipc_mux_dl_cmdresps_decode_process(struct iosm_mux *ipc_mux,
>  					      const union mux_cmd_param *param,
> +					      size_t param_len,
>  					      __le32 command_type, u8 if_id,
>  					      __le32 transaction_id)
>  {

[Severity: Low]
This patch has Cc: stable and Fixes: 9413491e20e1. Its context, though,
depends on the earlier series patch "net: wwan: iosm: pass the DL command
parameter by pointer", which has neither a Cc: stable nor a Fixes: tag.

In the stable trees, ipc_mux_dl_cmdresps_decode_process() still takes
union mux_cmd_param by value, and the callers pass cmdh->param. The
prerequisite also introduced two things this patch changes:

  - the acb->got_param = *param line removed here
  - the ipc_mux_dl_acbcmd_decode() body rewritten here

So this patch won't apply on its own.

Suppose the length checks are adapted by hand onto the by-value signature.
Each call would still copy the full 12-byte union out of the skb before
param_len is checked, so the over-read this series removes would remain.

The fix also relies on "net: wwan: iosm: bound the ACBH command chain
walk" and "net: wwan: iosm: validate the MUX DL block length".

Could the prerequisite be tagged for stable as well? Alternatively, the
prerequisite annotations from Documentation/process/stable-kernel-rules.rst
would make the ordering clear to backporters.

[ ... ]

> @@ -315,19 +329,36 @@ 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;
>  	__le32 trans_id = cmdh->transaction_id;
> -	int size;
> +	u16 cmd_len;
> +	int ret, size;
>  
> -	if (ipc_mux_dl_cmdresps_decode_process(ipc_mux, &cmdh->param,
> -					       cmdh->command_type, cmdh->if_id,
> -					       cmdh->transaction_id)) {
> +	cmd_len = le16_to_cpu(cmdh->cmd_len);
> +	param_len = skb->len > hdr_len ? skb->len - hdr_len : 0;
> +	/*
> +	 * A cmd_len below the header is not a usable declaration: the
> +	 * received length stays the limit, as for a legacy device.
> +	 */
> +	if (cmd_len >= hdr_len)
> +		param_len = min_t(size_t, param_len, cmd_len - hdr_len);
> +
> +	ret = ipc_mux_dl_cmdresps_decode_process(ipc_mux, &cmdh->param,
> +						 param_len,
> +						 cmdh->command_type,
> +						 cmdh->if_id,
> +						 cmdh->transaction_id);
> +	if (ret == -EMSGSIZE)
> +		return;

[Severity: Medium]
Can this bound reject MUX Lite commands that were handled before?

Once cmd_len >= 16, param_len becomes min(skb->len - 16, cmd_len - 16).

Take a FLOW_CTL with cmd_len 0x10 (the header-only minimum mentioned in
the commit message) or 17..19. It ends up with param_len < 4. The new
check in ipc_mux_dl_cmds_decode_process() then returns before the existing
backward compatibility branch runs:

	if (param_len < sizeof(param->flow_ctl))
		return -EMSGSIZE;
	...
	if (param->flow_ctl.mask == cpu_to_le32(0xFFFFFFFF)) {
		/* Backward Compatibility */
		if (cmd_len == cpu_to_le16(size))
			session->flow_ctl_mask =
				le32_to_cpu(param->flow_ctl.mask);
		else
			session->flow_ctl_mask = ~0;

That branch was added for MUX Lite in 9413491e20e1. There, size is
offsetof(struct mux_lite_cmdh, param) + sizeof(flow_ctl), so the branch
expects Lite FLOW_CTL commands whose cmd_len is not 20.

Before this patch, such a command was applied and acknowledged as long as
the mask was in the received bytes. With this patch, net_tx_stop and
flow_ctl_mask are left unchanged and no MUX_LITE_CMD_FLOW_CTL_ACK is sent.

An OPEN_SESSION_RESP with cmd_len 16..27 is affected the same way, even
when all 12 parameter bytes arrived. The chain is:

ipc_mux_dl_cmd_decode()
  ipc_mux_dl_cmdresps_decode_process() returns -EMSGSIZE
  return (silent)

The blocking ipc_mux_session_open_send() then runs out
IPC_MUX_CMD_RUN_DEFAULT_TIMEOUT and fails. The only message logged is
"OPEN_SESSION send failed".

It isn't clear whether shipping firmware uses these lengths. However, the
commit message says:

  the received length keeps the limit there, which preserves the handling
  the existing backward compatible code gives legacy devices

It also argues that cmd_len is not a hard bound on the aggregated path,
because the flow control decoder treats a mismatched cmd_len as a legacy
device. Wouldn't the same reasoning apply to MUX Lite, where that
compatibility code came from?

Should cmd_len bound the parameter only when it covers the member being
read? Or should the 16..19 and 16..27 cases at least be logged and
mentioned in the commit message?

> +
> +	if (ret) {
>  		/* Unable to decode command response indicates the cmd_type
>  		 * may be a command instead of response. So try to decoding it.
>  		 */
> -		size = offsetof(struct mux_lite_cmdh, param) +
> -				sizeof(cmdh->param.flow_ctl);
> +		size = hdr_len + sizeof(cmdh->param.flow_ctl);
>  		if (!ipc_mux_dl_cmds_decode_process(ipc_mux, &cmdh->param,
> -						    cmdh->command_type,
> +						    param_len, cmdh->command_type,
>  						    cmdh->if_id,
>  						    cmdh->cmd_len, size)) {

[ ... ]

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

      reply	other threads:[~2026-11-16 13:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 12:51 [PATCH net 0/5] net: wwan: iosm: validate MUX DL lengths and offsets Fang Xieyan
2026-11-12 12:51 ` [PATCH net 1/5] net: wwan: iosm: validate the MUX DL block length Fang Xieyan
2026-11-12 12:51 ` [PATCH net 2/5] net: wwan: iosm: validate the ADGH datagram length Fang Xieyan
2026-11-16 13:55   ` netdev-bot+sashiko
2026-11-12 12:51 ` [PATCH net 3/5] net: wwan: iosm: bound the ACBH command chain walk Fang Xieyan
2026-11-12 12:52 ` [PATCH net 4/5] net: wwan: iosm: pass the DL command parameter by pointer Fang Xieyan
2026-11-12 12:52 ` [PATCH net 5/5] net: wwan: iosm: validate the command parameter length Fang Xieyan
2026-11-16 13:55   ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179483731920.3136.4345864455275657786@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fangxy@xiaopeng.com \
    --cc=horms@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=m.chetan.kumar@linux.intel.com \
    --cc=maoyixie.tju@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=zhugl3@xiaopeng.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox