From: David Westen <davidlwesten@gmail.com>
To: netdev@vger.kernel.org
Cc: Loic Poulain <loic.poulain@oss.qualcomm.com>,
Sergey Ryazanov <ryazanov.s.a@gmail.com>,
Johannes Berg <johannes@sipsolutions.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
M Chetan Kumar <m.chetan.kumar@intel.com>,
"Maciej S. Szmigiero" <mail@maciej.szmigiero.name>,
David Westen <davidlwesten@gmail.com>
Subject: [PATCH net v3 1/2] net: wwan: iosm: free the MUX after the netdevs that use it
Date: Thu, 26 Nov 2026 11:41:42 -0800 [thread overview]
Message-ID: <20261126194143.32283-2-davidlwesten@gmail.com> (raw)
In-Reply-To: <20261126194143.32283-1-davidlwesten@gmail.com>
ipc_imem_cleanup() frees the MUX before it removes the netdevs, so
closing a netdev that is up uses the freed MUX:
BUG: KASAN: slab-use-after-free in ipc_mux_close_session
Call Trace:
ipc_mux_close_session
ipc_wwan_link_stop
__dev_close_many
wwan_unregister_ops
ipc_wwan_deinit
ipc_imem_cleanup
ipc_pcie_remove
Free the MUX last, after debugfs, the ports and the netdevs. Closing
the netdev then tells the modem to close the session, so that it stops
writing into the MUX buffers before they are freed. The reply is
ignored, as for the port closes. Ring the doorbell for the command at
once, as the cleanup has already cancelled the TD update timer.
Reproduced with KASAN on an XMM7360 by unbinding the driver while
wwan0 is up. With this change, three such unbinds show no report.
Fixes: 3670970dd8c6 ("net: iosm: shared memory IPC interface")
Signed-off-by: David Westen <davidlwesten@gmail.com>
---
drivers/net/wwan/iosm/iosm_ipc_imem.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c
index 4405c8531888..3ab409166c50 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_imem.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c
@@ -178,7 +178,8 @@ void ipc_imem_msg_send_feature_set(struct iosm_imem *ipc_imem,
void ipc_imem_td_update_timer_start(struct iosm_imem *ipc_imem)
{
/* Use the TD update timer only in the runtime phase */
- if (!ipc_imem->enter_runtime || ipc_imem->td_update_timer_suspended) {
+ if (!ipc_imem->enter_runtime || ipc_imem->td_update_timer_suspended ||
+ ipc_imem->phase == IPC_P_OFF_REQ) {
/* trigger the doorbell irq on CP directly. */
ipc_protocol_doorbell_trigger(ipc_imem->ipc_protocol,
IPC_HP_TD_UPD_TMR_START);
@@ -1244,10 +1245,10 @@ void ipc_imem_cleanup(struct iosm_imem *ipc_imem)
cancel_work_sync(&ipc_imem->run_state_worker);
if (test_and_clear_bit(FULLY_FUNCTIONAL, &ipc_imem->flag)) {
- ipc_mux_deinit(ipc_imem->mux);
ipc_debugfs_deinit(ipc_imem);
- ipc_wwan_deinit(ipc_imem->wwan);
ipc_port_deinit(ipc_imem->ipc_port);
+ ipc_wwan_deinit(ipc_imem->wwan);
+ ipc_mux_deinit(ipc_imem->mux);
}
if (test_and_clear_bit(IOSM_DEVLINK_INIT, &ipc_imem->flag))
--
2.56.0
next prev parent reply other threads:[~2026-11-26 19:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 19:41 [PATCH net v3 0/2] net: wwan: iosm: fix S3 resume by re-binding the driver after it David Westen
2026-11-26 19:41 ` David Westen [this message]
2026-11-26 19:41 ` [PATCH net v3 2/2] net: wwan: iosm: re-bind the driver when the modem rebooted during S3 David Westen
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=20261126194143.32283-2-davidlwesten@gmail.com \
--to=davidlwesten@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=m.chetan.kumar@intel.com \
--cc=mail@maciej.szmigiero.name \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ryazanov.s.a@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