numam-spdk/lib/nvmf
Seth Howell 12f85fa320 nvmf: don't keep a global discovery log page.
Keeping a global discovery log page was meant to be a time saving
mechanism, but in the current implementation, it doesn't work properly,
and can cause undesirable behavior and potential crashes. There are two
main problems with keeping a global log page.

1. Admin qpairs can be assigned to any SPDK thread. This means that when
multiple initiators connect to the host and request the discovery log,
they can both be running through the spdk_nvmf_ctrlr_get_log_page
function at the same time. In the event that the discovery generation
counter is incremented while these accesses are occurring, it can cause
one or both of the threads to update the log at the same time. This
results in both logs trying to free the old log page (double free) and
set their log as the new one (possible memory leak).

2. The second problem is that each host is supposed to get a unique
discovery log based on the subsystems to which they have access.
Currently the code relies on whether the discovery log page offset in
the request is equal to 0 to determine if it should load a new discovery
log page or use the cached one. This is inherently faulty because it
relies on initiator provided value to determine what information to
provide from the log page. An initiator could easily send a discovery
request with an offset greater than 0 on purpose to procure most of a
log page provided to another host.

Overall, I think it's safest to not cache the log page at all anymore
and rely on a thread local fresh log page each time.

Reported-by: Curt Bruns <curt.e.bruns@intel.com>

Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466839 (master)

(cherry picked from commit 20b35d769d)
Change-Id: Ib048e26f139927d888fed7019e0deec346359582
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467594
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-09-10 22:27:45 +00:00
..
ctrlr_bdev.c nvmf: Add BDEV IO pending statistics 2019-07-12 12:46:29 +00:00
ctrlr_discovery.c nvmf: don't keep a global discovery log page. 2019-09-10 22:27:45 +00:00
ctrlr.c nvmf: Delay sending AER until subsystem resumes 2019-09-09 21:55:22 +00:00
fc_ls.c NVMe-oF Target: Add FC transport. 2019-07-26 22:17:17 +00:00
fc.c NVMe-oF Target: Add FC transport. 2019-07-26 22:17:17 +00:00
Makefile NVMe-oF Target: Add FC transport. 2019-07-26 22:17:17 +00:00
nvmf_fc.h NVMe-oF Target: Add FC transport. 2019-07-26 22:17:17 +00:00
nvmf_internal.h nvmf: don't keep a global discovery log page. 2019-09-10 22:27:45 +00:00
nvmf.c nvmf: don't keep a global discovery log page. 2019-09-10 22:27:45 +00:00
rdma.c nvmf/rdma: Fix data WR release 2019-09-09 21:55:22 +00:00
subsystem.c nvmf: spdk_nvmf_subsystem_remove_ns is no longer asynchronous 2019-07-11 11:19:53 +00:00
tcp.c nvmf/tcp: Remove spdk_nvmf_tcp_qpair_process_pending 2019-07-26 21:16:23 +00:00
transport.c NVMe-oF Target: Add FC transport. 2019-07-26 22:17:17 +00:00
transport.h NVMe-oF Target: Add FC transport. 2019-07-26 22:17:17 +00:00