lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEf4BzaxQ029c8ofsq7PLWJX8xXVO0xDrnF908+6kXF7yQnGow@mail.gmail.com>
Date:   Sat, 19 Feb 2022 16:49:52 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Daniel Borkmann <daniel@...earbox.net>
Cc:     Mauricio Vásquez <mauricio@...volk.io>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Andrii Nakryiko <andrii@...nel.org>,
        Quentin Monnet <quentin@...valent.com>
Subject: Re: [PATCH bpf-next] bpftool: Remove usage of reallocarray()

On Fri, Feb 18, 2022 at 3:30 PM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> On 2/18/22 9:39 PM, Mauricio Vásquez wrote:
> > This commit fixes a compilation error on systems with glibc < 2.26 [0]:
> >
> > ```
> > In file included from main.h:14:0,
> >                   from gen.c:24:
> > linux/tools/include/tools/libc_compat.h:11:21: error: attempt to use poisoned "reallocarray"
> >   static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
> > ```
> >
> > This happens because gen.c pulls <bpf/libbpf_internal.h>, and then
> > <tools/libc_compat.h> (through main.h). When
> > COMPAT_NEED_REALLOCARRAY is set, libc_compat.h defines reallocarray()
> > which libbpf_internal.h poisons with a GCC pragma.
> >
> > This follows the same approach of libbpf in commit
> > 029258d7b228 ("libbpf: Remove any use of reallocarray() in libbpf").
> >
> > Reported-by: Quentin Monnet <quentin@...valent.com>
> > Signed-off-by: Mauricio Vásquez <mauricio@...volk.io>
> >
> > [0]: https://lore.kernel.org/bpf/3bf2bd49-9f2d-a2df-5536-bc0dde70a83b@isovalent.com/
> [...]
> > + * Copied from tools/lib/bpf/libbpf_internal.h
> > + */
> > +static inline void *bpftool_reallocarray(void *ptr, size_t nmemb, size_t size)
> > +{
> > +     size_t total;
> > +
> > +#if __has_builtin(__builtin_mul_overflow)
> > +     if (unlikely(__builtin_mul_overflow(nmemb, size, &total)))
> > +             return NULL;
> > +#else
> > +     if (size == 0 || nmemb > ULONG_MAX / size)
> > +             return NULL;
> > +     total = nmemb * size;
> > +#endif
> > +     return realloc(ptr, total);
> > +}
>
> Can't we just reuse libbpf_reallocarray() given we copy over libbpf_internal.h
> anyway via a9caaba399f9 ("bpftool: Implement "gen min_core_btf" logic")?
>

yep, no need to reimplement it

> Thanks,
> Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ