From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [bpf-next,v3,11/13] tools: bpf: make use of reallocarray Date: Fri, 13 Jul 2018 18:16:26 -0700 Message-ID: <20180713181626.2360c168@cakuba.lan> References: <20180710214307.4834-12-jakub.kicinski@netronome.com> <20180713235305.GA2779@roeck-us.net> <20180713170758.66b01079@cakuba.lan> <46440aba-be3f-a3d2-9f39-b7c2446ba50b@roeck-us.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: alexei.starovoitov@gmail.com, daniel@iogearbox.net, Andrey Ignatov , oss-drivers@netronome.com, netdev@vger.kernel.org To: Guenter Roeck Return-path: Received: from mail-qk0-f173.google.com ([209.85.220.173]:42855 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730230AbeGNBdg (ORCPT ); Fri, 13 Jul 2018 21:33:36 -0400 Received: by mail-qk0-f173.google.com with SMTP id 26-v6so7463011qks.9 for ; Fri, 13 Jul 2018 18:16:31 -0700 (PDT) In-Reply-To: <46440aba-be3f-a3d2-9f39-b7c2446ba50b@roeck-us.net> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 13 Jul 2018 17:31:34 -0700, Guenter Roeck wrote: > On 07/13/2018 05:07 PM, Jakub Kicinski wrote: > > On Fri, 13 Jul 2018 16:53:05 -0700, Guenter Roeck wrote: =20 > >> Hi, > >> > >> On Tue, Jul 10, 2018 at 02:43:05PM -0700, Jakub Kicinski wrote: =20 > >>> reallocarray() is a safer variant of realloc which checks for > >>> multiplication overflow in case of array allocation. Since it's > >>> not available in Glibc < 2.26 import kernel's overflow.h and > >>> add a static inline implementation when needed. Use feature > >>> detection to probe for existence of reallocarray. > >>> =20 > >> > >> This probe doesn't work on my system (Ubuntu 16.04). > >> > >> libbpf.c: In function =E2=80=98bpf_object__add_program=E2=80=99: > >> libbpf.c:326:10: error: implicit declaration of function =E2=80=98real= locarray=E2=80=99 =20 > >=20 > > No way :( :( Maybe you have to clean the build directory hard? > > Maybe you have old feature check results or some such? > > =20 >=20 > Unlikely. This is seen by my test builders which always start from a clea= n state. >=20 > $ lsb_release -a > No LSB modules are available. > Distributor ID: Ubuntu > Description: Ubuntu 16.04.4 LTS > Release: 16.04 > Codename: xenial > $ gcc --version > gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609 > Copyright (C) 2015 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOS= E. > $ ld --version > GNU ld (GNU Binutils for Ubuntu) 2.26.1 > Copyright (C) 2015 Free Software Foundation, Inc. > This program is free software; you may redistribute it under the terms of > the GNU General Public License version 3 or (at your option) a later vers= ion. > This program has absolutely no warranty. > $ git describe > next-20180713 > $ git clean -d -x -f -q > $ make allmodconfig > $ make tools/perf > ... > libbpf.c: In function =E2=80=98bpf_object__add_program=E2=80=99: > libbpf.c:326:10: error: implicit declaration of function =E2=80=98realloc= array=E2=80=99 Oh, you're not building perf! Looks like I missed adding reallocarray to the default feature set on which perf depends, and since given that features get reused (libbpf won't get to run its own feature detection) we have to test for reallocarray there: diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 5b6dda3b1ca8..f216b2f5c3d7 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -57,6 +57,7 @@ FEATURE_TESTS_BASIC :=3D \ libunwind-aarch64 \ pthread-attr-setaffinity-np \ pthread-barrier \ + reallocarray \ stackprotector-all \ timerfd \ libdw-dwarf-unwind \