nvmf/tcp: add hpda value check in 'nvmf_tcp_icreq_handle'
hpda value should be in range of 0 to 31. Signed-off-by: MengjinWu <mengjin.wu@intel.com> Change-Id: Ie1329c831af06ccc8943a562c3f6396b635be518 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14575 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
f8dd380b33
commit
1d7230285b
@ -550,6 +550,7 @@ SPDK_STATIC_ASSERT(offsetof(struct spdk_nvme_tcp_ic_req, pfv) == 8, "Incorrect o
|
||||
SPDK_STATIC_ASSERT(offsetof(struct spdk_nvme_tcp_ic_req, hpda) == 10, "Incorrect offset");
|
||||
SPDK_STATIC_ASSERT(offsetof(struct spdk_nvme_tcp_ic_req, maxr2t) == 12, "Incorrect offset");
|
||||
|
||||
#define SPDK_NVME_TCP_HPDA_MAX 31
|
||||
#define SPDK_NVME_TCP_CPDA_MAX 31
|
||||
#define SPDK_NVME_TCP_PDU_PDO_MAX_OFFSET ((SPDK_NVME_TCP_CPDA_MAX + 1) << 2)
|
||||
|
||||
|
@ -1906,6 +1906,14 @@ nvmf_tcp_icreq_handle(struct spdk_nvmf_tcp_transport *ttransport,
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* This value is 0’s based value in units of dwords should not be larger than SPDK_NVME_TCP_HPDA_MAX */
|
||||
if (ic_req->hpda > SPDK_NVME_TCP_HPDA_MAX) {
|
||||
SPDK_ERRLOG("ICReq HPDA out of range 0 to 31, got %u\n", ic_req->hpda);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
|
||||
error_offset = offsetof(struct spdk_nvme_tcp_ic_req, hpda);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* MAXR2T is 0's based */
|
||||
SPDK_DEBUGLOG(nvmf_tcp, "maxr2t =%u\n", (ic_req->maxr2t + 1u));
|
||||
|
||||
|
@ -897,7 +897,14 @@ test_nvmf_tcp_icreq_handle(void)
|
||||
|
||||
CU_ASSERT(tqpair.recv_state == NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||
|
||||
/* case 2: Expect: PASS. */
|
||||
/* case 2: Expected ICReq HPDA in range 0-31 and got are different. */
|
||||
pdu.hdr.ic_req.hpda = SPDK_NVME_TCP_HPDA_MAX + 1;
|
||||
|
||||
nvmf_tcp_icreq_handle(&ttransport, &tqpair, &pdu);
|
||||
|
||||
CU_ASSERT(tqpair.recv_state == NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||
|
||||
/* case 3: Expect: PASS. */
|
||||
ttransport.transport.opts.max_io_size = 32;
|
||||
pdu.hdr.ic_req.pfv = 0;
|
||||
tqpair.host_hdgst_enable = false;
|
||||
|
Loading…
Reference in New Issue
Block a user