aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/libbpf.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <[email protected]>2020-09-04 04:16:11 +0000
committerDaniel Borkmann <[email protected]>2020-09-04 12:35:12 +0000
commit8eb629585d2231e90112148009e2a11b0979ca38 (patch)
tree94ba49d2e25651fd880da37ce6e3252c3bd294fa /tools/lib/bpf/libbpf.c
parentlibbpf: Fix another __u64 cast in printf (diff)
downloadkernel-8eb629585d2231e90112148009e2a11b0979ca38.tar.gz
kernel-8eb629585d2231e90112148009e2a11b0979ca38.zip
libbpf: Fix potential multiplication overflow
Detected by LGTM static analyze in Github repo, fix potential multiplication overflow before result is casted to size_t. Fixes: 8505e8709b5e ("libbpf: Implement generalized .BTF.ext func/line info adjustment") Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
-rw-r--r--tools/lib/bpf/libbpf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 53be32a2b9fc..550950eb1860 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -5802,7 +5802,7 @@ static int adjust_prog_btf_ext_info(const struct bpf_object *obj,
/* append func/line info of a given (sub-)program to the main
* program func/line info
*/
- old_sz = (*prog_rec_cnt) * ext_info->rec_size;
+ old_sz = (size_t)(*prog_rec_cnt) * ext_info->rec_size;
new_sz = old_sz + (copy_end - copy_start);
new_prog_info = realloc(*prog_info, new_sz);
if (!new_prog_info)