mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] libbpf: Change hash_combine parameters from long to unsigned long
@ 2024-11-16  8:10 Sidong Yang
  2024-11-16 18:54 ` Yonghong Song
  2024-11-16 19:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Sidong Yang @ 2024-11-16  8:10 UTC (permalink / raw)
  To: Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Andrii Nakryiko, bpf, linux-kernel
  Cc: Sidong Yang

The hash_combine() could be trapped when compiled with sanitizer like "zig cc"
or clang with signed-integer-overflow option. This patch parameters and return
type to unsigned long to remove the potential overflow.

Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
---
 tools/lib/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 8befb8103e32..12468ae0d573 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -3548,7 +3548,7 @@ struct btf_dedup {
 	struct strset *strs_set;
 };
 
-static long hash_combine(long h, long value)
+static unsigned long hash_combine(unsigned long h, unsigned long value)
 {
 	return h * 31 + value;
 }
-- 
2.42.0


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

* Re: [PATCH] libbpf: Change hash_combine parameters from long to unsigned long
  2024-11-16  8:10 [PATCH] libbpf: Change hash_combine parameters from long to unsigned long Sidong Yang
@ 2024-11-16 18:54 ` Yonghong Song
  2024-11-16 19:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2024-11-16 18:54 UTC (permalink / raw)
  To: Sidong Yang, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Andrii Nakryiko, bpf, linux-kernel




On 11/16/24 12:10 AM, Sidong Yang wrote:
> The hash_combine() could be trapped when compiled with sanitizer like "zig cc"
> or clang with signed-integer-overflow option. This patch parameters and return
> type to unsigned long to remove the potential overflow.
>
> Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>

Acked-by: Yonghong Song <yonghong.song@linux.dev>


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

* Re: [PATCH] libbpf: Change hash_combine parameters from long to unsigned long
  2024-11-16  8:10 [PATCH] libbpf: Change hash_combine parameters from long to unsigned long Sidong Yang
  2024-11-16 18:54 ` Yonghong Song
@ 2024-11-16 19:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-16 19:10 UTC (permalink / raw)
  To: Sidong Yang
  Cc: martin.lau, eddyz87, song, yonghong.song, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, andrii.nakryiko, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Sat, 16 Nov 2024 17:10:52 +0900 you wrote:
> The hash_combine() could be trapped when compiled with sanitizer like "zig cc"
> or clang with signed-integer-overflow option. This patch parameters and return
> type to unsigned long to remove the potential overflow.
> 
> Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
> ---
>  tools/lib/bpf/btf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - libbpf: Change hash_combine parameters from long to unsigned long
    https://git.kernel.org/bpf/bpf-next/c/2c8b09ac2537

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-11-16 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-16  8:10 [PATCH] libbpf: Change hash_combine parameters from long to unsigned long Sidong Yang
2024-11-16 18:54 ` Yonghong Song
2024-11-16 19:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®