nvmf: return error on invalid req length for copy commands

Both the length of a request and the number of ranges to copy are
controlled by the user, so we should check them and return an error
instead of asserting that they're correct.

This fixes the `test/nvmf/target/fabrics_fuzz.sh` test.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I3481c4bb1f2c7676df81f41dfc95ef063924222e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15805
Reviewed-by: Pawel Piatek <pawelx.piatek@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Konrad Sztyber 2022-12-07 11:36:00 +01:00 committed by Tomasz Zawadzki
parent 38a8db4784
commit a64acd100c

View File

@ -681,7 +681,13 @@ nvmf_bdev_ctrlr_copy_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
cmd->cdw12_bits.copy.prinfow,
cmd->cdw12_bits.copy.fua,
cmd->cdw12_bits.copy.lr);
assert(req->length == (cmd->cdw12_bits.copy.nr + 1) * sizeof(struct spdk_nvme_scc_source_range));
if (spdk_unlikely(req->length != (cmd->cdw12_bits.copy.nr + 1) *
sizeof(struct spdk_nvme_scc_source_range))) {
response->status.sct = SPDK_NVME_SCT_GENERIC;
response->status.sc = SPDK_NVME_SC_DATA_SGL_LENGTH_INVALID;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
if (!spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_COPY)) {
SPDK_NOTICELOG("Copy command not supported by bdev\n");