All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] nvme: protect against possible request reference after completion
@ 2021-05-19 17:43 Sagi Grimberg
  2021-05-19 17:43 ` [PATCH v2 1/4] params: lift param_set_uint_minmax to common code Sagi Grimberg
                   ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: Sagi Grimberg @ 2021-05-19 17:43 UTC (permalink / raw)
  To: linux-nvme, Christoph Hellwig, Keith Busch; +Cc: Daniel Wagner

Nothing in nvme protects against referencing a request after it was completed.
For example, in case a buggy controller sends a completion twice for the same
request, the host can access and modify a request that was already completed.

At best, this will cause a panic, but on the worst case, this can cause a silent
data corruption if the request was already reused and executed by the time
we reference it.

The nvme command_id is an opaque that we simply placed the request tag thus far.
To protect against a access after completion, we introduce a generation counter
to the upper 4-bits of the command_id that will increment every invocation and
be validated upon the reception of a completion. This will limit the maximum
queue depth to be effectively 4095, but we hardly ever use such long queues
(in fabrics the maximum is already 1024).

Changes from v1:
- lift param_set_uint_minmax and reuse it
- simplify initialization in patch 3/4

Sagi Grimberg (4):
  params: lift param_set_uint_minmax to common code
  nvme-pci: limit maximum queue depth to 4095
  nvme-tcp: don't check blk_mq_tag_to_rq when receiving pdu data
  nvme: code command_id with a genctr for use-after-free validation

 drivers/nvme/host/core.c    |  3 ++-
 drivers/nvme/host/nvme.h    | 47 ++++++++++++++++++++++++++++++++++++-
 drivers/nvme/host/pci.c     | 17 ++++++--------
 drivers/nvme/host/rdma.c    |  4 ++--
 drivers/nvme/host/tcp.c     | 38 ++++++++++++------------------
 drivers/nvme/target/loop.c  |  4 ++--
 include/linux/moduleparam.h |  3 +++
 kernel/params.c             | 19 +++++++++++++++
 net/sunrpc/xprtsock.c       | 18 --------------
 9 files changed, 96 insertions(+), 57 deletions(-)

-- 
2.27.0


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

end of thread, other threads:[~2021-07-09  6:38 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-19 17:43 [PATCH v2 0/4] nvme: protect against possible request reference after completion Sagi Grimberg
2021-05-19 17:43 ` [PATCH v2 1/4] params: lift param_set_uint_minmax to common code Sagi Grimberg
2021-05-19 21:10   ` Chaitanya Kulkarni
2021-05-20  6:01   ` Christoph Hellwig
2021-05-19 17:43 ` [PATCH v2 2/4] nvme-pci: limit maximum queue depth to 4095 Sagi Grimberg
2021-05-19 21:12   ` Chaitanya Kulkarni
2021-05-26  8:55   ` Hannes Reinecke
2021-05-19 17:43 ` [PATCH v2 3/4] nvme-tcp: don't check blk_mq_tag_to_rq when receiving pdu data Sagi Grimberg
2021-05-26  8:56   ` Hannes Reinecke
2021-05-19 17:43 ` [PATCH v2 4/4] nvme: code command_id with a genctr for use-after-free validation Sagi Grimberg
2021-05-20  6:49   ` Daniel Wagner
2021-05-25 22:50   ` Max Gurtovoy
2021-05-26  0:39     ` Keith Busch
2021-05-26  1:47       ` Chaitanya Kulkarni
2021-05-26  8:41         ` Sagi Grimberg
2021-05-26  8:48           ` Hannes Reinecke
2021-05-26  9:26           ` Max Gurtovoy
2021-05-26  8:59   ` Hannes Reinecke
2021-06-16 16:28 ` [PATCH v2 0/4] nvme: protect against possible request reference after completion Sagi Grimberg
2021-06-16 17:04   ` Keith Busch
2021-06-16 21:05     ` Sagi Grimberg
2021-07-01 11:51       ` Daniel Wagner
2021-07-01 11:52         ` Christoph Hellwig
2021-07-08 10:02           ` Daniel Wagner
2021-07-09  6:37             ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.