net/enic: fix raw item length check

Currently, the raw item is always preceded by a UDP header, and both
land in the L4 pattern buffer. So consider the UDP header size when
checking if the raw spec fits in the L4 buffer.

Coverity issue: 336796, 336850
Fixes: 477959e6ee ("net/enic: enable limited support for raw flow item")

Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
Reviewed-by: John Daley <johndale@cisco.com>
This commit is contained in:
Hyong Youb Kim 2019-04-08 23:40:26 -07:00 committed by Ferruh Yigit
parent 97d37d2c1f
commit 37b07be28a

View File

@ -967,7 +967,8 @@ enic_copy_item_raw_v2(struct copy_item_args *arg)
if (!spec->relative || spec->offset != 0 || spec->search || spec->limit)
return EINVAL;
/* Need non-null pattern that fits within the NIC's filter pattern */
if (spec->length == 0 || spec->length > FILTER_GENERIC_1_KEY_LEN ||
if (spec->length == 0 ||
spec->length + sizeof(struct udp_hdr) > FILTER_GENERIC_1_KEY_LEN ||
!spec->pattern || !mask->pattern)
return EINVAL;
/*