From: David Westen <davidlwesten@gmail.com>
To: netdev@vger.kernel.org
Cc: 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@intel.com,
mail@maciej.szmigiero.name
Subject: [PATCH net] net: wwan: iosm: clear the MUX pointer after freeing the MUX
Date: Tue, 1 Dec 2026 06:55:53 -0800 [thread overview]
Message-ID: <20261201145553.14624-1-davidlwesten@gmail.com> (raw)
ipc_imem_cleanup() frees the MUX but leaves ipc_imem->mux pointing at
it, so closing a netdev that is still 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
Clear the pointer after the free; ipc_imem_sys_wwan_close() already
skips the session close when it is NULL. Do the same in the error path
of the run state worker.
Reproduced with KASAN on an XMM7360 by unbinding the driver while
wwan0 is up. With this change, two such unbinds show no report.
Fixes: 3670970dd8c6 ("net: iosm: shared memory IPC interface")
Fixes: 60829145f1e2 ("net: wwan: iosm: fix NULL pointer dereference when removing device")
Signed-off-by: David Westen <davidlwesten@gmail.com>
---
Previously sent as patch 1/2 of a series:
https://lore.kernel.org/netdev/20261126194143.32283-1-davidlwesten@gmail.com/
drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c
index 4405c8531888..998493b730b0 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_imem.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c
@@ -635,6 +635,7 @@ static void ipc_imem_run_state_worker(struct work_struct *instance)
err_ipc_mux_deinit:
ipc_mux_deinit(ipc_imem->mux);
+ ipc_imem->mux = NULL;
err_out:
ipc_uevent_send(ipc_imem->dev, UEVENT_CD_READY_LINK_DOWN);
}
@@ -1245,6 +1246,7 @@ void ipc_imem_cleanup(struct iosm_imem *ipc_imem)
if (test_and_clear_bit(FULLY_FUNCTIONAL, &ipc_imem->flag)) {
ipc_mux_deinit(ipc_imem->mux);
+ ipc_imem->mux = NULL;
ipc_debugfs_deinit(ipc_imem);
ipc_wwan_deinit(ipc_imem->wwan);
ipc_port_deinit(ipc_imem->ipc_port);
--
2.56.0
reply other threads:[~2026-12-01 14:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201145553.14624-1-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