Skip to content

Commit 16ebb6f

Browse files
Dan Carpenterkuba-moo
authored andcommitted
nfp: bpf: prevent integer overflow in nfp_bpf_event_output()
The "sizeof(struct cmsg_bpf_event) + pkt_size + data_size" math could potentially have an integer wrapping bug on 32bit systems. Check for this and return an error. Fixes: 9816dd3 ("nfp: bpf: perf event output helpers support") Signed-off-by: Dan Carpenter <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f62bb88 commit 16ebb6f

File tree

1 file changed

+2
-1
lines changed
  • drivers/net/ethernet/netronome/nfp/bpf

1 file changed

+2
-1
lines changed

drivers/net/ethernet/netronome/nfp/bpf/offload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ int nfp_bpf_event_output(struct nfp_app_bpf *bpf, const void *data,
458458
map_id_full = be64_to_cpu(cbe->map_ptr);
459459
map_id = map_id_full;
460460

461-
if (len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size)
461+
if (size_add(pkt_size, data_size) > INT_MAX ||
462+
len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size)
462463
return -EINVAL;
463464
if (cbe->hdr.ver != NFP_CCM_ABI_VERSION)
464465
return -EINVAL;

0 commit comments

Comments
 (0)