Skip to content

nvme: fix racy access to FDP placement ID array

Hari Mishal linux-nvme lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 20 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2nvme: fix racy access to FDP placement ID arraydrivers/nvme/host/core.c drivers/nvme/host/nvme.h+43 -215 replies
2/2nvme: drop WARN_ON_ONCE on write_stream bounds checkdrivers/nvme/host/core.c+1 -115 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] nvme: fix racy access to FDP placement ID array

nvme_ns_head can be shared across multiple nvme_ns paths (multipath, or dual-port/multi-controller subsystems). nvme_query_fdp_info() populates head->nr_plids/head->plids the first time a namespace's FDP configuration is registered, but nothing protects that pair from concurrent access - two paths scanning the same namespace at the same time can race to populate it, and depending on how the writes interleave a concurrent reader can hit a NULL dereference or an out-of-bounds read.

Patch 1 adds a spinlock and closes the race.

Patch 2 is a small, unrelated cleanup on code sitting right next to what patch 1 touches: it drops a WARN_ON_ONCE that turns out to be unreachable through any current path, since the value it guards against is already validated upstream in the block layer and F2FS before a bio ever carries it. Happy to drop this one or send it separately if you'd rather keep it out of this series.

Hari Mishal (2):
nvme: fix racy access to FDP placement ID array
nvme: drop WARN_ON_ONCE on write_stream bounds check

 drivers/nvme/host/core.c | 63 ++++++++++++++++++++++++++--------------
 drivers/nvme/host/nvme.h |  1 +
 2 files changed, 43 insertions(+), 21 deletions(-)
Signature · 1 line
2.43.0