All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Andrii Nakryiko <andrii@kernel.org>, bpf@vger.kernel.org, ast@kernel.org
Cc: kernel-team@fb.com
Subject: Re: [PATCH bpf-next 03/13] libbpf: prevent UBSan from complaining about integer overflow
Date: Fri, 26 Nov 2021 00:19:31 +0100	[thread overview]
Message-ID: <8350db18-6e13-66da-220c-c1e53562326e@iogearbox.net> (raw)
In-Reply-To: <9e00239a-b44c-88d9-39b4-5e0ad7d49f3b@iogearbox.net>

On 11/25/21 11:21 PM, Daniel Borkmann wrote:
> On 11/24/21 1:23 AM, Andrii Nakryiko wrote:
>> Integer overflow is intentional, silence the sanitizer. It works
>> completely reliably on sane compilers and architectures.
>>
>> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
>> ---
>>   tools/lib/bpf/btf.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
>> index 8024fe355ca8..be1dafd56a13 100644
>> --- a/tools/lib/bpf/btf.c
>> +++ b/tools/lib/bpf/btf.c
>> @@ -3127,6 +3127,7 @@ struct btf_dedup {
>>       struct strset *strs_set;
>>   };
>> +__attribute__((no_sanitize("signed-integer-overflow")))
>>   static long hash_combine(long h, long value)
>>   {
>>       return h * 31 + value;
>>
> 
> Sgtm, I guess my only question, was there a reason for not using e.g. __u64 in
> the first place? Meaning, __u64 hash_combine(__u64 h, __u64 value) plus the
> call-sites where you have h variable re-feeding into hash_combine().

Given the remainder of the series is all straight forward, I took that in already,
but would still be nice if we can silence the sanitizer complaint w/o such attribute
workaround.

Thanks,
Daniel

  reply	other threads:[~2021-11-25 23:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  0:23 [PATCH bpf-next 00/13] Fix sanitizer-reported libbpf and selftest issues Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 01/13] tools/resolve_btf_ids: close ELF file on error Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 02/13] libbpf: fix potential misaligned memory access in btf_ext__new() Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 03/13] libbpf: prevent UBSan from complaining about integer overflow Andrii Nakryiko
2021-11-25 22:21   ` Daniel Borkmann
2021-11-25 23:19     ` Daniel Borkmann [this message]
2021-11-26  1:23       ` Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 04/13] libbpf: don't call libc APIs with NULL pointers Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 05/13] libbpf: fix glob_syms memory leak in bpf_linker Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 06/13] libbpf: fix using invalidated memory " Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 07/13] selftests/bpf: fix UBSan complaint about signed __int128 overflow Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 08/13] selftests/bpf: fix possible NULL passed to memcpy() with zero size Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 09/13] selftests/bpf: prevent misaligned memory access in get_stack_raw_tp test Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 10/13] selftests/bpf: fix misaligned memory access in queue_stack_map test Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 11/13] selftests/bpf: prevent out-of-bounds stack access in test_bpffs Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 12/13] selftests/bpf: fix misaligned memory accesses in xdp_bonding test Andrii Nakryiko
2021-11-24  0:23 ` [PATCH bpf-next 13/13] selftests/bpf: fix misaligned accesses in xdp and xdp_bpf2bpf tests Andrii Nakryiko

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=8350db18-6e13-66da-220c-c1e53562326e@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=kernel-team@fb.com \
    /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.