Skip to content

Commit 640f700

Browse files
jahay1anguy11
authored andcommitted
idpf: use actual mbx receive payload length
When a mailbox message is received, the driver is checking for a non 0 datalen in the controlq descriptor. If it is valid, the payload is attached to the ctlq message to give to the upper layer. However, the payload response size given to the upper layer was taken from the buffer metadata which is _always_ the max buffer size. This meant the API was returning 4K as the payload size for all messages. This went unnoticed since the virtchnl exchange response logic was checking for a response size less than 0 (error), not less than exact size, or not greater than or equal to the max mailbox buffer size (4K). All of these checks will pass in the success case since the size provided is always 4K. However, this breaks anyone that wants to validate the exact response size. Fetch the actual payload length from the value provided in the descriptor data_len field (instead of the buffer metadata). Unfortunately, this means we lose some extra error parsing for variable sized virtchnl responses such as create vport and get ptypes. However, the original checks weren't really helping anyways since the size was _always_ 4K. Fixes: 34c21fa ("idpf: implement virtchnl transaction manager") Cc: [email protected] # 6.9+ Signed-off-by: Joshua Hay <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Tested-by: Krishneil Singh <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent d382c7b commit 640f700

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ idpf_vc_xn_forward_reply(struct idpf_adapter *adapter,
666666

667667
if (ctlq_msg->data_len) {
668668
payload = ctlq_msg->ctx.indirect.payload->va;
669-
payload_size = ctlq_msg->ctx.indirect.payload->size;
669+
payload_size = ctlq_msg->data_len;
670670
}
671671

672672
xn->reply_sz = payload_size;
@@ -1295,10 +1295,6 @@ int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
12951295
err = reply_sz;
12961296
goto free_vport_params;
12971297
}
1298-
if (reply_sz < IDPF_CTLQ_MAX_BUF_LEN) {
1299-
err = -EIO;
1300-
goto free_vport_params;
1301-
}
13021298

13031299
return 0;
13041300

@@ -2602,9 +2598,6 @@ int idpf_send_get_rx_ptype_msg(struct idpf_vport *vport)
26022598
if (reply_sz < 0)
26032599
return reply_sz;
26042600

2605-
if (reply_sz < IDPF_CTLQ_MAX_BUF_LEN)
2606-
return -EIO;
2607-
26082601
ptypes_recvd += le16_to_cpu(ptype_info->num_ptypes);
26092602
if (ptypes_recvd > max_ptype)
26102603
return -EINVAL;

0 commit comments

Comments
 (0)