mbox series

[v2,0/1] switchtec: Fix stdev_release crash after suprise device loss.

Message ID 20231110201917.89016-1-dns@arista.com (mailing list archive)
Headers show
Series switchtec: Fix stdev_release crash after suprise device loss. | expand

Message

Daniel Stodden Nov. 10, 2023, 8:19 p.m. UTC
Hello.

Sorry for sending the same set twice in a row, but I found a
typo in yesterday's recipients list.

Here goes a small shell script to crash a kernel in switchtec.ko's
stdev_release.

--snip--
#!/bin/bash -x
# open cdev
exec 3<>/dev/switchtec0
# remove pdev
addr=$(basename $(realpath /sys/class/switchtec/switchtec0/../..))
echo 1 > /sys/bus/pci/devices/$addr/remove
# close cdev
exec 3>&-
--snip--

It worked on v5.10. I believe it has been working ever since. The
problem is that keeping the stdev pinned past the pci_driver removal
will defer the mrpc dma shutdown until way after devres_release_all,
which unmapped stdev->mmio_mrpc. Also, stdev->pdev would be a stale
pointer by then.

Followed-up with a humble proposal how to fix it.

Thanks,
Daniel

Daniel Stodden (1):
  switchtec: Fix stdev_release crash after suprise device loss.

 drivers/pci/switch/switchtec.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)