Skip to content

mtd: spi-nor: Fix unbind deadlock and use-after-free

[email protected] linux-mtd lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mtd: spi-nor: Fix deadlock in spi_nor_rww_start_exclusive()drivers/mtd/spi-nor/core.c+1 -12 replies
2/2mtd: spi-nor: core: Fix use-after-free of spi_nor on unbind with open handlesdrivers/mtd/spi-nor/core.c include/linux/mtd/spi-nor.h+118 -102 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] mtd: spi-nor: Fix unbind deadlock and use-after-free

From: Tze Yee Ng <[email protected]>

Two fixes in the spi-nor core around locking and driver unbind:

Patch 1 fixes a self-deadlock in spi_nor_rww_start_exclusive(), which took nor->lock while its end helper re-acquired it via guard(mutex).

Patch 2 fixes a use-after-free where a sysfs unbind frees the devm-allocated spi_nor while /dev/mtdX is still open. Give it a kref lifetime on the spi-mem probe path and fail operations with -ENODEV after unbind. Legacy controllers are unchanged.

Tze Yee Ng (2):
mtd: spi-nor: Fix deadlock in spi_nor_rww_start_exclusive()
mtd: spi-nor: core: Fix use-after-free of spi_nor on unbind with open
handles

 drivers/mtd/spi-nor/core.c  | 113 ++++++++++++++++++++++++++++++++----
 include/linux/mtd/spi-nor.h |  17 ++++++
 2 files changed, 119 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.7