Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: tim770802@gmail.com
Cc: netdev@vger.kernel.org, chandrashekar.devegowda@intel.com,
	haijun.liu@mediatek.com, ricardo.martinez@linux.intel.com,
	loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com,
	johannes@sipsolutions.net, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, ilpo.jarvinen@linux.intel.com,
	sreehari.kancharla@linux.intel.com,
	m.chetan.kumar@linux.intel.com, horms@kernel.org,
	linux-kernel@vger.kernel.org, tim.jh.chen@wnc.com.tw,
	Chih.Hung.Huang@wnc.com.tw
Subject: Re: [PATCH net v7 3/6] net: wwan: t7xx: fix skb double free when CLDMA send sees -EACCES
Date: Tue, 24 Nov 2026 02:29:39 +0000	[thread overview]
Message-ID: <179548737980.3135.2481190514948803907@kernel.org> (raw)
In-Reply-To: <20261120015556.131547-4-tim770802@gmail.com>

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

Critical: 1 · High: 0 · Medium: 0 · 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).

- [Critical] The patch fixes only one way to hit the skb double free;
  another one remains.
- [Low] net: wwan: t7xx: wrong Fixes tag and caller names in commit
  message

--

net: wwan: t7xx: fix skb double free when CLDMA send sees -EACCES

This patch changes t7xx_cldma_send_skb() to take the runtime PM reference
with pm_runtime_get_noresume() and to resume with pm_runtime_resume(), so
one reference is held across the send. It also clears ret after the resume,
so a tolerated -EACCES is not returned for an skb that was already queued.
Returning that -EACCES made the callers free the skb a second time.

> diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
> index e1b37deb6d9bf..5b4b9ed4a95b9 100644
> --- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
> +++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
> @@ -926,9 +926,17 @@ int t7xx_cldma_send_skb(struct cldma_ctrl *md_ctrl, int qno, struct sk_buff *skb
>  	if (qno >= CLDMA_TXQ_NUM)
>  		return -EINVAL;
>  
> -	ret = pm_runtime_resume_and_get(md_ctrl->dev);
> -	if (ret < 0 && ret != -EACCES)
> +	pm_runtime_get_noresume(md_ctrl->dev);
> +	ret = pm_runtime_resume(md_ctrl->dev);
> +	if (ret < 0 && ret != -EACCES) {
> +		pm_runtime_put_noidle(md_ctrl->dev);
>  		return ret;
> +	}
> +
> +	/* ret holds the resume status (1 for an active device, -EACCES with
> +	 * runtime PM disabled), not the result of the send below.
> +	 */
> +	ret = 0;

[Severity: Low]
This isn't a runtime problem, but the commit message needs a couple of
corrections before this goes to stable.

The Fixes tag points at 46e8f49ed7b3 ("net: wwan: t7xx: Introduce power
management"). As far as I can tell, that commit only added the system
sleep callbacks:

  t7xx_cldma_suspend()
  t7xx_cldma_suspend_late()
  t7xx_cldma_resume_early()
  t7xx_cldma_resume()

It did not touch t7xx_cldma_send_skb() and did not add any runtime PM
calls.

Three pieces of t7xx_cldma_send_skb() came in with d10b3a695ba0 ("net:
wwan: t7xx: Runtime PM"):

  - the pm_runtime_resume_and_get() call
  - the ret != -EACCES check
  - the matching pm_runtime_put_autosuspend()

Should the tag be the following instead?

  Fixes: d10b3a695ba0 ("net: wwan: t7xx: Runtime PM")

An incorrect Fixes tag sends the backport to the wrong set of stable
branches.

The message also names t7xx_port_fastboot_write() and
t7xx_port_wwan_write() as the callers that free the skb on a non-zero
return. Neither function appears to exist in the tree. The actual
callers are:

  - t7xx_port_fastboot_tx() in t7xx_port_wwan.c, which frees tx_skb
  - t7xx_port_ctrl_tx() in t7xx_port_wwan.c, which frees cloned
  - port_ctl_send_msg_to_md() in t7xx_port_ctrl_msg.c, which frees
    the skb with dev_kfree_skb_any()

Could you update the description to name those, so the double-free
explanation can be checked against the code?

[Severity: Critical]
This fixes the -EACCES case. Can the same double free still happen through
the -ETIMEDOUT return later in t7xx_cldma_send_skb()?

In the first branch of the do/while loop, the skb is placed on the ring
before the sleep-disable wait is checked:

drivers/net/wwan/t7xx/t7xx_hif_cldma.c:t7xx_cldma_send_skb() {
    ...
			queue->budget--;
			t7xx_cldma_gpd_handle_tx_request(queue, tx_req, skb);
			queue->tx_next = list_next_entry_circular(tx_req, gpd_ring, entry);
			spin_unlock_irqrestore(&queue->ring_lock, flags);

			if (!t7xx_pci_sleep_disable_complete(md_ctrl->t7xx_dev)) {
				ret = -ETIMEDOUT;
				break;
			}
    ...
}

By this point t7xx_cldma_gpd_handle_tx_request() has DMA-mapped skb->data,
set GPD_FLAGS_HWO if the queue is active, and stored tx_req->skb = skb.

If the modem does not ack the DS lock within PM_SLEEP_DIS_TIMEOUT_MS
(20 ms), the function returns -ETIMEDOUT. The skb stays on the ring, still
mapped and with HWO set.

The callers treat any non-zero return as "not sent" and free the skb:

  t7xx_port_fastboot_tx()    -> dev_kfree_skb(tx_skb)
  t7xx_port_ctrl_tx()        -> dev_kfree_skb(cloned)
  port_ctl_send_msg_to_md()  -> dev_kfree_skb_any(skb)

Later, t7xx_cldma_gpd_tx_collect() sees HWO cleared and req->skb non-NULL.
It then calls dma_unmap_single() and dev_kfree_skb_any() on the
already-freed skb. On reset, t7xx_cldma_clear_txq() frees req->skb in the
same way.

Until then, the next t7xx_cldma_hw_start_send() or queue resume would let
the modem DMA from the freed buffer.

The new comment says ret should only report the result of the send below.
Should every return after a successful queue report success? The other
option is to take the request back off the ring (unmap, clear HWO, clear
tx_req->skb, restore budget and tx_next) before returning an error.

The later patches in this series do not appear to touch
t7xx_hif_cldma.c, so this path would remain at the end of the series.

>  
>  	t7xx_pci_disable_sleep(md_ctrl->t7xx_dev);
>  	queue = &md_ctrl->txq[qno];

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120015556.131547-1-tim770802%40gmail.com

  reply	other threads:[~2026-11-24  2:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  1:55 [PATCH net v7 0/6] net: wwan: t7xx: fix TX push kthread soft lockup on suspend and RX stop issues Tim JH Chen
2026-11-20  1:55 ` [PATCH net v7 1/6] net: wwan: t7xx: fix TX push kthread soft lockup on system suspend Tim JH Chen
2026-11-20  1:55 ` [PATCH net v7 2/6] net: wwan: t7xx: fix runtime PM usage count underflow on -EACCES Tim JH Chen
2026-11-24  2:29   ` netdev-bot+sashiko
2026-11-20  1:55 ` [PATCH net v7 3/6] net: wwan: t7xx: fix skb double free when CLDMA send sees -EACCES Tim JH Chen
2026-11-24  2:29   ` netdev-bot+sashiko [this message]
2026-11-20  1:55 ` [PATCH net v7 4/6] net: wwan: t7xx: do not exit the TX push kthread on resume failure Tim JH Chen
2026-11-24  2:29   ` netdev-bot+sashiko
2026-11-20  1:55 ` [PATCH net v7 5/6] net: wwan: t7xx: complete NAPI on the not-started RX poll early return Tim JH Chen
2026-11-20  1:55 ` [PATCH net v7 6/6] net: wwan: t7xx: fix memory ordering in t7xx_dpmaif_rx_stop() Tim JH Chen
2026-11-24  2:29   ` netdev-bot+sashiko
2026-11-20  2:03 ` [PATCH net v7 0/6] net: wwan: t7xx: fix TX push kthread soft lockup on suspend and RX stop issues netdev-bot+sinfo
2026-11-20  2:42   ` Tim JH Chen

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=179548737980.3135.2481190514948803907@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Chih.Hung.Huang@wnc.com.tw \
    --cc=andrew+netdev@lunn.ch \
    --cc=chandrashekar.devegowda@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=haijun.liu@mediatek.com \
    --cc=horms@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ricardo.martinez@linux.intel.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=sreehari.kancharla@linux.intel.com \
    --cc=tim.jh.chen@wnc.com.tw \
    --cc=tim770802@gmail.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