Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvmet_fc: Accept variable pad lengths on Create Association LS

Target validation of the Create Association LS revised to accept any
LS as long as all non-pad data has been received. This allows a (newer)
target to accept the LS from older initiators with varying pad lengths.

Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>

authored by

James Smart and committed by
Sagi Grimberg
4cb7ca80 d1438ad8

+13 -7
+13 -7
drivers/nvme/target/fc.c
··· 1164 1164 1165 1165 memset(acc, 0, sizeof(*acc)); 1166 1166 1167 - if (iod->rqstdatalen < sizeof(struct fcnvme_ls_cr_assoc_rqst)) 1167 + /* 1168 + * FC-NVME spec changes. There are initiators sending different 1169 + * lengths as padding sizes for Create Association Cmd descriptor 1170 + * was incorrect. 1171 + * Accept anything of "minimum" length. Assume format per 1.15 1172 + * spec (with HOSTID reduced to 16 bytes), ignore how long the 1173 + * trailing pad length is. 1174 + */ 1175 + if (iod->rqstdatalen < FCNVME_LSDESC_CRA_RQST_MINLEN) 1168 1176 ret = VERR_CR_ASSOC_LEN; 1169 - else if (rqst->desc_list_len != 1170 - fcnvme_lsdesc_len( 1171 - sizeof(struct fcnvme_ls_cr_assoc_rqst))) 1177 + else if (rqst->desc_list_len < 1178 + cpu_to_be32(FCNVME_LSDESC_CRA_RQST_MIN_LISTLEN)) 1172 1179 ret = VERR_CR_ASSOC_RQST_LEN; 1173 1180 else if (rqst->assoc_cmd.desc_tag != 1174 1181 cpu_to_be32(FCNVME_LSDESC_CREATE_ASSOC_CMD)) 1175 1182 ret = VERR_CR_ASSOC_CMD; 1176 - else if (rqst->assoc_cmd.desc_len != 1177 - fcnvme_lsdesc_len( 1178 - sizeof(struct fcnvme_lsdesc_cr_assoc_cmd))) 1183 + else if (rqst->assoc_cmd.desc_len < 1184 + cpu_to_be32(FCNVME_LSDESC_CRA_CMD_DESC_MIN_DESCLEN)) 1179 1185 ret = VERR_CR_ASSOC_CMD_LEN; 1180 1186 else if (!rqst->assoc_cmd.ersp_ratio || 1181 1187 (be16_to_cpu(rqst->assoc_cmd.ersp_ratio) >=