netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf
@ 2020-09-04  4:16 Andrii Nakryiko
  2020-09-04  4:16 ` [PATCH bpf-next 2/2] libbpf: fix potential multiplication overflow Andrii Nakryiko
  2020-09-04 13:09 ` [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf Daniel Borkmann
  0 siblings, 2 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2020-09-04  4:16 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Another issue of __u64 needing either %lu or %llu, depending on the
architecture. Fix with cast to `unsigned long long`.

Fixes: 7e06aad52929 ("libbpf: Add multi-prog section support for struct_ops")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 47b43c13eee5..53be32a2b9fc 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -8224,7 +8224,7 @@ static int bpf_object__collect_st_ops_relos(struct bpf_object *obj,
 		}
 		if (sym.st_value % BPF_INSN_SZ) {
 			pr_warn("struct_ops reloc %s: invalid target program offset %llu\n",
-				map->name, (__u64)sym.st_value);
+				map->name, (unsigned long long)sym.st_value);
 			return -LIBBPF_ERRNO__FORMAT;
 		}
 		insn_idx = sym.st_value / BPF_INSN_SZ;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH bpf-next 2/2] libbpf: fix potential multiplication overflow
  2020-09-04  4:16 [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf Andrii Nakryiko
@ 2020-09-04  4:16 ` Andrii Nakryiko
  2020-09-04 13:09 ` [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2020-09-04  4:16 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

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 <andriin@fb.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf
  2020-09-04  4:16 [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf Andrii Nakryiko
  2020-09-04  4:16 ` [PATCH bpf-next 2/2] libbpf: fix potential multiplication overflow Andrii Nakryiko
@ 2020-09-04 13:09 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-09-04 13:09 UTC (permalink / raw)
  To: Andrii Nakryiko, bpf, netdev, ast; +Cc: andrii.nakryiko, kernel-team

On 9/4/20 6:16 AM, Andrii Nakryiko wrote:
> Another issue of __u64 needing either %lu or %llu, depending on the
> architecture. Fix with cast to `unsigned long long`.
> 
> Fixes: 7e06aad52929 ("libbpf: Add multi-prog section support for struct_ops")
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-04 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04  4:16 [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf Andrii Nakryiko
2020-09-04  4:16 ` [PATCH bpf-next 2/2] libbpf: fix potential multiplication overflow Andrii Nakryiko
2020-09-04 13:09 ` [PATCH bpf-next 1/2] libbpf: fix another __u64 cast in printf Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).