summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/qualcomm/qca_spi.c
diff options
context:
space:
mode:
authorStefan Wahren <wahrenst@gmx.net>2023-12-06 17:12:20 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-20 17:44:27 +0300
commita07e5568d95f879127793ac4eb825885ab6cdcf9 (patch)
tree1e81f9461977c69771a903b4aa0d6b7d70e3d773 /drivers/net/ethernet/qualcomm/qca_spi.c
parent97275e470c2a6d19916b47b631d6ec3bd4427566 (diff)
downloadlinux-a07e5568d95f879127793ac4eb825885ab6cdcf9.tar.xz
qca_debug: Prevent crash on TX ring changes
[ Upstream commit f4e6064c97c050bd9904925ff7d53d0c9954fc7b ] The qca_spi driver stop and restart the SPI kernel thread (via ndo_stop & ndo_open) in case of TX ring changes. This is a big issue because it allows userspace to prevent restart of the SPI kernel thread (via signals). A subsequent change of TX ring wrongly assume a valid spi_thread pointer which result in a crash. So prevent this by stopping the network traffic handling and temporary park the SPI thread. Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Link: https://lore.kernel.org/r/20231206141222.52029-2-wahrenst@gmx.net Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/qualcomm/qca_spi.c')
-rw-r--r--drivers/net/ethernet/qualcomm/qca_spi.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 44fa959ebcaa..b08a4b2a6a99 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -573,6 +573,18 @@ qcaspi_spi_thread(void *data)
netdev_info(qca->net_dev, "SPI thread created\n");
while (!kthread_should_stop()) {
set_current_state(TASK_INTERRUPTIBLE);
+ if (kthread_should_park()) {
+ netif_tx_disable(qca->net_dev);
+ netif_carrier_off(qca->net_dev);
+ qcaspi_flush_tx_ring(qca);
+ kthread_parkme();
+ if (qca->sync == QCASPI_SYNC_READY) {
+ netif_carrier_on(qca->net_dev);
+ netif_wake_queue(qca->net_dev);
+ }
+ continue;
+ }
+
if ((qca->intr_req == qca->intr_svc) &&
!qca->txr.skb[qca->txr.head])
schedule();