Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH v3 0/1] switchtec: Fix stdev_release crash after suprise device loss.
@ 2023-11-13 21:21 Daniel Stodden
  2023-11-13 21:21 ` [PATCH v3] " Daniel Stodden
  0 siblings, 1 reply; 15+ messages in thread
From: Daniel Stodden @ 2023-11-13 21:21 UTC (permalink / raw)
  To: Kurt Schwemmer, Logan Gunthorpe, linux-pci; +Cc: Daniel Stodden

Hello.

Changes since v2:
 * Inline/remove disable_dma_mrpc.
 * Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

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

-- 
2.41.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-11-22  3:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-13 21:21 [PATCH v3 0/1] switchtec: Fix stdev_release crash after suprise device loss Daniel Stodden
2023-11-13 21:21 ` [PATCH v3] " Daniel Stodden
2023-11-20 21:25   ` Bjorn Helgaas
2023-11-21 18:23     ` Daniel Stodden
2023-11-21 18:40       ` Bjorn Helgaas
2023-11-21 23:58         ` Daniel Stodden
2023-11-22  0:02           ` Daniel Stodden
2023-11-22  0:39             ` Bjorn Helgaas
2023-11-22  0:19           ` Bjorn Helgaas
2023-11-22  0:25             ` Dmitry Safonov
2023-11-22  0:37               ` Bjorn Helgaas
2023-11-22  0:37   ` Dmitry Safonov
2023-11-22  0:41     ` Bjorn Helgaas
2023-11-22  1:02       ` Daniel Stodden
2023-11-22  3:16         ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox