🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20729

Re: [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding the driver around it

#20729
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 05:17
211 lines
15651 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

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

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).

- [High] Use-after-free in the remove path, which this patch now runs on
  every S3 suspend while the modem is live.
- [Medium] When the card keeps power, the modem now goes into system
  sleep fully awake.
- [Low] The new PM_POST_SUSPEND branch in pm_notify() registers the
  driver again based only on the global `pci_registered` flag, which…
- [Low] The stable backport prerequisite is not declared.

--

net: wwan: iosm: fix S3 resume by re-binding the driver around it

This patch extends the iosm PM notifier. It now unregisters the PCI driver
on PM_SUSPEND_PREPARE, unless the default suspend mode is s2idle, and
registers it again on PM_POST_SUSPEND. This reuses the hibernation
mechanism from commit 0b6f6593aa8c, so the modem is probed again after it
reboots during S3.

> Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support")
> Cc: stable@vger.kernel.org

[Severity: Low]
Will this apply to the stable trees that this Fixes: tag selects?

Commit 0b6f6593aa8c ("net: wwan: iosm: Fix hibernation by re-binding the
driver around it") added pm_notify(), pm_notifier and pci_registered. That
commit has no Fixes: or Cc: stable tag. A tree that has 1f52d7b62285 but
not 0b6f6593aa8c has no pm_notify() at all.

Could the prerequisite be named, for example with
"Cc: stable@vger.kernel.org # depends on 0b6f6593aa8c"?

The dependency on the preceding ADB timer patch is only described below
the --- line. That patch carries the same Fixes: and stable tags, so that
part is less of a concern.

> diff --git a/drivers/net/wwan/iosm/iosm_ipc_pcie.c b/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> index 49052eb511baa..13e81012d818c 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> @@ -534,12 +534,17 @@ void ipc_pcie_kfree_skb(struct iosm_pcie *ipc_pcie, struct sk_buff *skb)
>  
>  static int pm_notify(struct notifier_block *nb, unsigned long mode, void *_unused)
>  {
> -	if (mode == PM_HIBERNATION_PREPARE || mode == PM_RESTORE_PREPARE) {
> +	/* The modem may lose power in S3 and S4 and boot again on resume,
> +	 * which the suspend/resume callbacks can't handle, so probe it again.
> +	 */
> +	if (mode == PM_HIBERNATION_PREPARE || mode == PM_RESTORE_PREPARE ||
> +	    (mode == PM_SUSPEND_PREPARE && !pm_suspend_default_s2idle())) {
>  		if (pci_registered) {
>  			pci_unregister_driver(&iosm_ipc_driver);
>  			pci_registered = false;
>  		}

[Severity: High]
Can this expose a use-after-free of ipc_imem->ipc_task on every S3
suspend?

Here pci_unregister_driver() goes through ipc_pcie_remove() into
ipc_pcie_cleanup(). That function frees the imem resources before it
releases the MSI handlers:

drivers/net/wwan/iosm/iosm_ipc_pcie.c:ipc_pcie_cleanup() {
	/* Free the shared memory resources. */
	ipc_imem_cleanup(ipc_pcie->imem);

	ipc_pcie_resources_release(ipc_pcie);
	...
}

Inside ipc_imem_cleanup(), the CP is told to go to IPC UNINIT. Then the
tasklet and its container are freed, and the pointer is not cleared:

drivers/net/wwan/iosm/iosm_ipc_imem.c:ipc_imem_cleanup() {
	...
	ipc_imem_device_ipc_uninit(ipc_imem);
	ipc_imem_channel_reset(ipc_imem);

	ipc_protocol_deinit(ipc_imem->ipc_protocol);
	ipc_task_deinit(ipc_imem->ipc_task);

	kfree(ipc_imem->ipc_task);
	...
}

The threaded MSI handler is still registered at that point. Its only gate
is the s2idle suspend bit, and this path never sets it:

drivers/net/wwan/iosm/iosm_ipc_irq.c:ipc_msi_interrupt() {
	...
	if (!test_bit(0, &ipc_pcie->suspend))
		ipc_imem_irq_process(ipc_pcie->imem, instance);
	...
}

ipc_imem_irq_process() only checks ev_irq_pending[irq].
ipc_imem_handle_irq() clears that flag before its IPC_P_OFF_REQ early
return, so the flag doesn't block a new enqueue either.

An MSI that arrives after tasklet_kill() in ipc_task_deinit() schedules
the tasklet again just before it is kfree'd. An MSI that arrives after
kfree(ipc_imem->ipc_task) makes ipc_task_queue_add_task() read and write
the freed structure:

	struct tasklet_struct *ipc_tasklet = ipc_imem->ipc_task->ipc_tasklet;
	struct ipc_task_queue *ipc_task = &ipc_imem->ipc_task->ipc_queue;
	...
	spin_lock_irqsave(&ipc_task->q_lock, flags);
	...
	tasklet_schedule(ipc_tasklet);

The softirq could then run that tasklet after ipc_pcie_deinit() has also
freed imem and ipc_pcie.

The unbind and hibernation paths already use this ordering. This patch
puts it on the S3 path while the modem is running and has just been told
to go to UNINIT. Could the MSIs be quiesced or freed before
ipc_imem_cleanup() tears down the tasklet?

[Severity: Medium]
Does the modem now enter system sleep in D0 with its firmware still
running? This applies when the card keeps power in S3, or when freeze or
standby is entered while mem_sleep is deep.

The driver is unbound at PM_SUSPEND_PREPARE, so ipc_pcie_suspend_cb() no
longer runs and neither sleep handshake is sent:

	switch (ipc_pcie->d3l2_support) {
	case IPC_PCIE_D0L12:
		ipc_pcie_suspend_s2idle(ipc_pcie);
		break;
	case IPC_PCIE_D3L2:
		ipc_pcie_suspend(ipc_pcie);
		break;
	}

This skips both the IPC_MEM_DEV_PM_FORCE_SLEEP doorbell and the
ipc_imem_pm_suspend() host sleep message.

The PCI core also stops putting the device into a low power state. With no
driver bound, pci_pm_suspend_noirq() takes this branch and never reaches
pci_prepare_to_sleep():

drivers/pci/pci-driver.c:pci_pm_suspend_noirq() {
	...
	if (!pm) {
		pci_save_state(pci_dev);
		goto set_unknown;
	}
	...
}

Before suspend, the modem only gets IPC UNINIT from
ipc_imem_device_ipc_uninit(), which is not a sleep request.

Could this raise sleep power, or keep the platform out of S0ix during an
explicit s2idle? The changelog lists lost data sessions for these cases,
but it doesn't mention this.

> -	} else if (mode == PM_POST_HIBERNATION || mode == PM_POST_RESTORE) {
> +	} else if (mode == PM_POST_HIBERNATION || mode == PM_POST_RESTORE ||
> +		   mode == PM_POST_SUSPEND) {
>  		if (!pci_registered) {
>  			int ret;

[Severity: Low]
Can this register the driver again in the middle of a uswsusp
hibernation?

The hibernation and suspend paths now share pci_registered.
snapshot_open() sends PM_HIBERNATION_PREPARE, which unbinds iosm. It then
drops system_transition_mutex while /dev/snapshot stays open:

kernel/power/user.c:snapshot_open() {
	...
	error = pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE, PM_POST_HIBERNATION);
	...
 Unlock:
	unlock_system_sleep(sleep_flags);
	...
}

enter_state() only does a trylock on that mutex:

	if (!mutex_trylock(&system_transition_mutex))
		return -EBUSY;

Suppose a suspend to RAM starts before SNAPSHOT_FREEZE. PM_SUSPEND_PREPARE
does nothing because the driver is already unregistered. PM_POST_SUSPEND
then calls pci_register_driver() and sets pci_registered = true.

The hibernation image would then be created with iosm bound. The later
PM_POST_HIBERNATION from snapshot_release() does nothing, so the unbind
added by 0b6f6593aa8c is lost. Before this patch PM_POST_SUSPEND was
ignored, so this couldn't happen.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119042714.505405-1-davidlwesten%40gmail.com
Technical Details
Message-ID: <179541107082.3135.11504382259893948340@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369047-linux-kernel-netdev=dewy.ru
References: <20261119042714.505405-2-davidlwesten@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369047-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding
 the driver around it
Date: Mon, 23 Nov 2026 05:17:50 +0000
Organization: Usenet Network
Message-ID: <179541107082.3135.11504382259893948340@kernel.org>
References: <20261119042714.505405-2-davidlwesten@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3798395"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:z9wHWWFrt6FMgXm9zBbsBerCsR4= sha256:v6YU5YPqI6+imSWWcUfD2Bs4iUM9r37s3au0toC3k88=
	sha1:QeEzFidwiBNgQN+A9eRdLlUPXC0= sha256:/nK06s7z8u6GoxJf947Ng7rxmDMWBeL11zDh1nJnAO0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6017E125D8E; Mon, 23 Nov 2026 08:18:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id A7t169BJEYg4;
	Mon, 23 Nov 2026 08:18:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369047-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 46349125D89; Mon, 23 Nov 2026 08:18:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 308C82DC56; Mon, 23 Nov 2026 05:17:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795411078;
	b=p0rUD0CvLmd4/2Kthh3IeFXePv6BEidZ/VuHXGbnXhDYdqeW1Y12TvuylbnypJxkLFLj
	 DFaqtj3VEoq5kf+CRF3HKhGBXGOPgEZLyussl6c28L2/7E1+t5jXijwXZ5GBxYbo+aRfd
	 WyQe8QEVm1B6iU3yvvhwGmb/0BWxroGIYmr4NGAS9F90wdMEtC0cHnifmP0JC3hXbDAYr
	 duKFnidfMl8yxbQcf4ZHM+XrT8IIRMW2PDBjh7u5TCFS+Qn4ZqnM9e2MlpS5MEEbITZ+L
	 QzpXxQcLvs49d0+whsdUcLKyS/ogosMoO7Tky222KfpWlh8+uDBhwTGGIIpKJppSuwg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795411078;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=p4ilBBmu4wqkUrExqEeONwlOBor94s/7aXOC9EBEpWM=;
	b=VwdazIY4a72VZ1Sf+cyIe/aGoOzVIEVnY1LQEFs4xNa+8dLfYe2mKqvsxWZwZFmousPd
	 STXoYzhIKLUHf62X/KbjNUAT4oRnqHWfmm2NS1SmeW6W2riaTtaet7p5YQ3rzXakaEBja
	 sOgS0d6rumeGz5qaOD1t+MBLvPmBLQL352a7EpV/5bREasbaimWbb0Rw+5fBgNkwhjLVV
	 oKivINFG8PSI8MatpqvfSV9NyoFTLwcX/I9tjQY3E21e5klZ/NVcHw5AawlG7UheXJ72H
	 ahSo57Ua1v0WpihFU0lHlMvUz+ryQ2+nUIT5jBNJjpiy+GtjkQ4NfXkKUDadEMxPs+A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NHyDgflT;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 06463606A321;
	Mon, 23 Nov 2026 05:17:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NHyDgflT
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795411072;
	b=fgpl31Bsp8sxbiZel9maCKMYAjXbjLrpL4aLNnaMmhBKoTRIvgnXhSnGfENsgeRRif8G
	 dJ7y4vrDpOhi47TYIpqx5CMQrsGEzn3Q48hsEafVsXUqk9u6/2NOEv3/vdbZrVFlwH1wE
	 X8YYfWWQtC7qMIQ1JHFONapT/fyfRRLKDsAJPAU2W76AigemsC6iktV3uaWS7LW+Md1qo
	 aSkQbTbpRx3EIb9MsV19h6u/7VUKTSVolxY/3MWXhXRu3xxRxqEHaoh3ktP3hiyXV2lCO
	 4RPDsggj3/d7BqltRHpVFCt+SntEE6nbzD0z3uWreZxkNl1WrK4/lgnuuCR4NeyJwNw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795411072;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=p4ilBBmu4wqkUrExqEeONwlOBor94s/7aXOC9EBEpWM=;
	b=VDk5cPPgDYvwJtIxA0P8DREDBhGYcH9lKz9tBL7WdvEQCuNZuvt7xC6PnE53LABoIjpO
	 m3SKi3z3xj3Pu03LysaQhIUbcNs0L5y8wNi4eJUkUBJaCCHXagIlhRCFUhXGvSzZ6vvPj
	 OGj5XVIaSZKNTn4P9OjqcvtE4cSEMsKhUZw970O1qobXsQSDr+aLS9hvQxoyoxNKruWKO
	 gkSRqwC/7exhG3ywx1rUwyKL2+4HxCxT6E8JjFic8WQihaSibiUtrS9N1WHdUaAU2X9FP
	 +JQtU6DLfvSHA9g45ZgeU6Gr/B4526mDUdQQTMzrMrHku2pO7No66TEr18rGUTwgG/A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NHyDgflT;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21FC3606A336;
	Mon, 23 Nov 2026 05:17:52 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39EE11F000D0;
	Mon, 23 Nov 2026 05:17:51 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795411072;
	bh=p4ilBBmu4wqkUrExqEeONwlOBor94s/7aXOC9EBEpWM=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=NHyDgflTwXBT0Xrs/2H7JNc/Ij6du99K29Hen2VvceONUtEVCZPe/gMDTEsACnoD4
	 jQcXlEiqM+m7RpoJeRL89u+S/s5s/6/QORkAKrGQQ/llMbDTipUcndCyTtpgl+o5hE
	 m6NlDdBns9q3ORCl73/RSZP2kwXAj3QkQbv847fno+hQ9iFANo54HZJmizfA/dqO97
	 g36qpeo8TW6gjtLt7JaAimXuuhfr0hYRlBuxGj6Vwgq8UgjNfwG7esbQ4F2zQermt8
	 QE8dORK7CE/EDGvx4SaK6yrruBuDBz0wMuh0pC2XAPB8vmqcdKbXLln7js4GcLW0Qf
	 3hdJ+h1sHXZzw==
X-Cc: netdev@vger.kernel.org, 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,
 m.chetan.kumar@linux.intel.com, linux-kernel@vger.kernel.org,
 mail@maciej.szmigiero.name, nihaal@cse.iitm.ac.in, stable@vger.kernel.org
X-In-Reply-To: <20261119042714.505405-2-davidlwesten@gmail.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list