Spdk/lib/nvmf
Alexey Marchuk e16f4bc7ce lib/nvmf: Defer port removal while qpairs exist in poll group
The following heap-use-after-free may happen when RDMA listener
is removed:
1. At least 2 listeners exist, at least 1 qpair is created
on each listening port
2. Listener A is removed, in nvmf_stop_listen_disconnect_qpairs
we iterate all qpair (let's say A1 and B1) and we check if qpair's
source trid matches listener's trid by calling
nvmf_transport_qpair_get_listen_trid. Trid is retrieved from
qpair->listen_id which points to the listener A cmid. Assume that
qpair's A1 trid matches, A1 starts the disconnect process
3. After iterating all qpairs on step 2 we switch to the next
IO channel and then complete port removal on RDMA transport
layer where we destroy cmid of the listener A
4. Qpair A1 still has IO submitted to bdev, destruction is postponed
5. Listener B is removed, in nvmf_stop_listen_disconnect_qpairs
we iterate all qpairs (A1 and B1) and try to check A1's listen trid.
But listener A is already destroyed, so RDMA qpair->listen_id points
to freed memory chunk

To fix this issue, nvmf_stop_listen_disconnect_qpairs was modified
to ensure that no qpairs with listen_trid == removed_trid exist
before destroying the listener.

Fixes issue #2948

Signed-off-by: Alexey Marchuk <alexeymar@nvidia.com>
Change-Id: Iba263981ff02726f0c850bea90264118289e500c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17287
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2023-05-09 17:58:11 +08:00
..
ctrlr_bdev.c bdev: Add default copy command support in bdev 2023-03-07 11:52:45 +00:00
ctrlr_discovery.c update Intel copyright notices 2022-11-10 08:28:53 +00:00
ctrlr.c lib/nvmf: Update spdk_nvmf_qpair_disconnect return value 2023-05-09 17:58:11 +08:00
fc_ls.c lib/nvmf: Do not use cb_fn in spdk_nvmf_qpair_disconnect 2023-05-09 17:58:11 +08:00
fc.c nvmf/fc: delegate memory object free to LLD 2023-05-09 17:58:11 +08:00
Makefile so_ver: increase all major versions 2023-01-24 08:37:21 +00:00
nvmf_fc.h update Intel copyright notices 2022-11-10 08:28:53 +00:00
nvmf_internal.h nvmf: make async event and error related functions public 2023-03-31 17:41:35 +00:00
nvmf_rpc.c nvmf: introduce async transport create 2023-02-16 16:45:08 +00:00
nvmf.c nvmf: initialize trid param in get_***_trid paths 2023-05-09 17:58:11 +08:00
rdma.c nvmf/tcp, nvmf/rdma: default to dynamic buf_cache_size 2023-03-28 20:17:21 +00:00
spdk_nvmf.map nvmf: make async event and error related functions public 2023-03-31 17:41:35 +00:00
subsystem.c nvmf: handle iovecs in reservation handling 2023-02-13 13:50:51 +00:00
tcp.c nvmf/tcp: Wait for PDUs to release when closing a qpair 2023-05-09 17:58:11 +08:00
transport.c lib/nvmf: Defer port removal while qpairs exist in poll group 2023-05-09 17:58:11 +08:00
transport.h update Intel copyright notices 2022-11-10 08:28:53 +00:00
vfio_user.c nvmf/vfio_user: Post SQ delete cpl when qpair is destroyed 2023-05-09 17:58:11 +08:00