mirror of https://lore.kernel.org/lkml/
 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, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
	horms@kernel.org, johannes@sipsolutions.net,
	maoyixie.tju@gmail.com, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, zhugl3@xiaopeng.com
Subject: Re: [PATCH net v2 3/5] net: wwan: iosm: bound the ACBH command chain walk
Date: Sat, 21 Nov 2026 18:05:30 +0000	[thread overview]
Message-ID: <179528433079.3135.7229744100791190249@kernel.org> (raw)
In-Reply-To: <20261117173940.34970-4-fangxy@xiaopeng.com>

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] This patch adds a new early return to ipc_mux_dl_acb_decode()
  in drivers/net/wwan/iosm/iosm_ipc_mux_codec.c: `if (block_length <…

--

net: wwan: iosm: bound the ACBH command chain walk

This patch reworks ipc_mux_dl_acb_decode() so that every command offset
in a received Aggregated Command Block is bounded by skb->len. It also
validates next_cmd_index so the walk always moves forward. It removes
the array_index_nospec() call and adds a sanity check on
acbh->block_length.

> diff --git a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> index 65421f6b4c91e..a8448e273c021 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_mux_codec.c
> @@ -526,30 +526,60 @@ static void ipc_mux_dl_acbcmd_decode(struct iosm_mux *ipc_mux,
>  /* Decode an aggregated command block. */
>  static void ipc_mux_dl_acb_decode(struct iosm_mux *ipc_mux, struct sk_buff *skb)
>  {

[ ... ]

>  	acbh = (struct mux_acbh *)(skb->data);
>  	block = (u8 *)(skb->data);
> +	block_length = le32_to_cpu(acbh->block_length);
>  
> -	next_cmd_index = le32_to_cpu(acbh->first_cmd_index);
> -	next_cmd_index = array_index_nospec(next_cmd_index,
> -					    sizeof(struct mux_cmdh));
> +	/*
> +	 * The uplink encoder leaves block_length at the ACBH header size.
> +	 * It cannot delimit the command chain, so use skb->len to bound
> +	 * the command offsets.
> +	 */
> +	if (block_length < sizeof(struct mux_acbh) || block_length > skb->len)
> +		return;

[Severity: Medium]
Could this new check drop every downlink ACB without any message on
some modem firmware?

Before this patch, the DL ACB decoder never read acbh->block_length.
Firmware has never had to keep it between sizeof(struct mux_acbh) and
skb->len. If the check fails, the function returns without logging
anything and the whole block is thrown away.

The comment above says block_length cannot delimit the command chain.
The loop below already bounds every command offset by skb->len. So the
check doesn't seem to add memory safety. Its only effect is that
commands can be dropped.

The only evidence of what this field holds comes from the host's uplink
encoder:

drivers/net/wwan/iosm/iosm_ipc_mux_codec.c:ipc_mux_acb_init() {
    ...
	header->block_length = cpu_to_le32(sizeof(struct mux_acbh));
	header->first_cmd_index = header->block_length;
    ...
}

ipc_mux_acb_add_cmd() never updates it. That doesn't match the
kernel-doc for struct mux_acbh in iosm_ipc_mux_codec.h:

 * @block_length:       Length (in bytes) of the Aggregated Command Block.

It also suggests the modem doesn't rely on this field in UL ACBs.
Nothing in the tree shows what the modem writes in DL ACBs.

If a firmware writes 0 here, or a value larger than the transfer,
wouldn't every DL ACB be dropped? Some of the effects:

  MUX_CMD_OPEN_SESSION_RESP is never processed. ipc_mux_session_open()
  then times out waiting for acb->got_response and fails.

  IOSM_AGGR_MUX_CMD_FLOW_CTL_ENABLE/DISABLE are never applied.
  session->net_tx_stop and session->flow_ctl_mask are not updated, and
  no FLOW_CTL_ACK is sent.

  LINK_STATUS_REPORT is never answered.

The ADB path isn't really a precedent. mux_dl_process_dg() checks each
datagram index against adbh->block_length as well as skb->len. ACBH
block_length, by contrast, was never read on the DL path before this
patch.

The check is still there after the later patch in this series, "net:
wwan: iosm: validate the command parameter length".

Is the block_length check needed here, since skb->len already bounds
the command chain walk?

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

  reply	other threads:[~2026-11-21 18:05 UTC|newest]

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

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=179528433079.3135.7229744100791190249@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=maoyixie.tju@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=stable@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®