Re: [PATCH] libbpf: fix signed multiplication overflow in hash_combine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 6/16/24 3:11 PM, psykose wrote:
when using -fsanitize=undefined (which flags signed overflow which is
UB), a crash can be reproduced when building the linux kernel with BTF
info.

cast to unsigned first to make the overflow not invoke UB semantics- the
result is the same.

Signed-off-by: psykose <alice@xxxxxxxxx>

This seems against upstream libbpf repo. Could you do a proper patch
against bpf-next tree. Please have details how to reproduce the failure.

Please use proper name in your Signed-off-by.

---
  src/btf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/btf.c b/src/btf.c
index 2d0840e..60cd412 100644
--- a/src/btf.c
+++ b/src/btf.c
@@ -3317,7 +3317,7 @@ struct btf_dedup {
static long hash_combine(long h, long value)
  {
-	return h * 31 + value;
+	return (long)((unsigned long)h * 31 + (unsigned long)value);
  }
#define for_each_dedup_cand(d, node, hash) \

base-commit: 42065ea6627ff6e1ab4c65e51042a70fbf30ff7c




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux