diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2025-01-13 07:18:39 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2025-01-14 23:55:25 +0100 |
commit | 16ebb6f5b6295c9688749862a39a4889c56227f8 (patch) | |
tree | c3277f7fff024b22bb46a6bd399721eb1e8bb16f | |
parent | Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/... (diff) | |
download | linux-16ebb6f5b6295c9688749862a39a4889c56227f8.tar.xz linux-16ebb6f5b6295c9688749862a39a4889c56227f8.zip |
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: 9816dd35ecec ("nfp: bpf: perf event output helpers support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/6074805b-e78d-4b8a-bf05-e929b5377c28@stanley.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/net/ethernet/netronome/nfp/bpf/offload.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/offload.c b/drivers/net/ethernet/netronome/nfp/bpf/offload.c index 9d97cd281f18..c03558adda91 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/offload.c +++ b/drivers/net/ethernet/netronome/nfp/bpf/offload.c @@ -458,7 +458,8 @@ int nfp_bpf_event_output(struct nfp_app_bpf *bpf, const void *data, map_id_full = be64_to_cpu(cbe->map_ptr); map_id = map_id_full; - if (len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size) + if (size_add(pkt_size, data_size) > INT_MAX || + len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size) return -EINVAL; if (cbe->hdr.ver != NFP_CCM_ABI_VERSION) return -EINVAL; |