kernel-aes67/drivers/nvme/target
Sagi Grimberg 73964c1d07 nvmet-rdma: fix possible bad dereference when freeing rsps
It is possible that the host connected and saw a cm established
event and started sending nvme capsules on the qp, however the
ctrl did not yet see an established event. This is why the
rsp_wait_list exists (for async handling of these cmds, we move
them to a pending list).

Furthermore, it is possible that the ctrl cm times out, resulting
in a connect-error cm event. in this case we hit a bad deref [1]
because in nvmet_rdma_free_rsps we assume that all the responses
are in the free list.

We are freeing the cmds array anyways, so don't even bother to
remove the rsp from the free_list. It is also guaranteed that we
are not racing anything when we are releasing the queue so no
other context accessing this array should be running.

[1]:
--
Workqueue: nvmet-free-wq nvmet_rdma_free_queue_work [nvmet_rdma]
[...]
pc : nvmet_rdma_free_rsps+0x78/0xb8 [nvmet_rdma]
lr : nvmet_rdma_free_queue_work+0x88/0x120 [nvmet_rdma]
 Call trace:
 nvmet_rdma_free_rsps+0x78/0xb8 [nvmet_rdma]
 nvmet_rdma_free_queue_work+0x88/0x120 [nvmet_rdma]
 process_one_work+0x1ec/0x4a0
 worker_thread+0x48/0x490
 kthread+0x158/0x160
 ret_from_fork+0x10/0x18
--

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
2024-05-08 06:17:01 -07:00
..
Kconfig
Makefile
admin-cmd.c
auth.c nvmet-auth: return the error code to the nvmet_auth_ctrl_hash() callers 2024-05-07 07:57:38 -07:00
configfs.c nvmet: prevent sprintf() overflow in nvmet_subsys_nsid_exists() 2024-05-08 06:10:32 -07:00
core.c nvmet: make nvmet_wq unbound 2024-05-07 08:07:05 -07:00
discovery.c
fabrics-cmd-auth.c
fabrics-cmd.c for-6.9/block-20240310 2024-03-11 11:43:44 -07:00
fc.c nvmet-fc: move RCU read lock to nvmet_fc_assoc_exists 2024-04-04 08:47:56 -07:00
fcloop.c nvme: fcloop: make fcloop_class constant 2024-03-05 07:56:21 -08:00
io-cmd-bdev.c
io-cmd-file.c
loop.c
nvmet.h nvmet: fix nvme status code when namespace is disabled 2024-05-01 02:58:43 -07:00
passthru.c
rdma.c nvmet-rdma: fix possible bad dereference when freeing rsps 2024-05-08 06:17:01 -07:00
tcp.c nvmet-tcp: fix possible memory leak when tearing down a controller 2024-05-01 02:58:42 -07:00
trace.c nvmet: add tracing of zns commands 2024-03-08 06:58:20 -08:00
trace.h
zns.c