With per channel stats called on thread A, spdk_bdev_for_each_channel calls spdk_for_each_channel which immediately sends a message to thread B. If thread B has no workload, it may execute the message relatively fast trying to write stats to json_write_ctx. As result, we may have 2 scenarious: 1. json_write_ctx is still not initialized on thread A, so thread B dereferences a NULL pointer. 1. json_write_ctx is initialized but thread A writes response header while thread B writes stats - it leads to corrupted json response. To fix this race condition, initialize json_write_ctx before iterating bdevs/channels Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Signed-off-by: Alexey Marchuk <alexeymar@nvidia.com> Reported-by: Or Gerlitz <ogerlitz@nvidia.com> Change-Id: I5dae37f1f527437528fc8a8e9c6066f69687dec9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16366 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> |
||
---|---|---|
.. | ||
bdev_internal.h | ||
bdev_rpc.c | ||
bdev_zone.c | ||
bdev.c | ||
Makefile | ||
part.c | ||
scsi_nvme.c | ||
spdk_bdev.map | ||
vtune.c |