All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: psykose <alice@ayaya.dev>, bpf@vger.kernel.org
Subject: Re: [PATCH] libbpf: fix signed multiplication overflow in hash_combine
Date: Sun, 16 Jun 2024 19:14:33 -0700	[thread overview]
Message-ID: <363d0b06-1249-4e8d-8ed0-8debac0eacaa@linux.dev> (raw)
In-Reply-To: <D21SEVE6F615.2LMUOCTGW8AI7@ayaya.dev>


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@ayaya.dev>

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

      reply	other threads:[~2024-06-17  2:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-16 22:11 [PATCH] libbpf: fix signed multiplication overflow in hash_combine psykose
2024-06-17  2:14 ` Yonghong Song [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=363d0b06-1249-4e8d-8ed0-8debac0eacaa@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=alice@ayaya.dev \
    --cc=bpf@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.