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 17:07:58 -0700 Message-ID: <20180713170758.66b01079@cakuba.lan> References: <20180710214307.4834-12-jakub.kicinski@netronome.com> <20180713235305.GA2779@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-qt0-f196.google.com ([209.85.216.196]:34599 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731210AbeGNAY4 (ORCPT ); Fri, 13 Jul 2018 20:24:56 -0400 Received: by mail-qt0-f196.google.com with SMTP id m13-v6so28628030qth.1 for ; Fri, 13 Jul 2018 17:08:02 -0700 (PDT) In-Reply-To: <20180713235305.GA2779@roeck-us.net> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 13 Jul 2018 16:53:05 -0700, Guenter Roeck wrote: > Hi, >=20 > On Tue, Jul 10, 2018 at 02:43:05PM -0700, Jakub Kicinski wrote: > > 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 >=20 > This probe doesn't work on my system (Ubuntu 16.04). >=20 > 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 No way :( :( Maybe you have to clean the build directory hard? =20 Maybe you have old feature check results or some such? # lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.2 LTS Release: 16.04 Codename: xenial # rm -rf /tmp/bpftool # mkdir /tmp/bpftool # make -C tools/bpf/bpftool/ O=3D/tmp/bpftool make: Entering directory '/tmp/linux/tools/bpf/bpftool' Auto-detecting system features: ... libbfd: [ OFF ] ... disassembler-four-args: [ OFF ] CC /tmp/bpftool/map_perf_ring.o CC /tmp/bpftool/xlated_dumper.o CC /tmp/bpftool/perf.o CC /tmp/bpftool/prog.o CC /tmp/bpftool/common.o CC /tmp/bpftool/cgroup.o CC /tmp/bpftool/main.o CC /tmp/bpftool/json_writer.o CC /tmp/bpftool/cfg.o CC /tmp/bpftool/map.o CC /tmp/bpftool/jit_disasm.o CC /tmp/bpftool/disasm.o make[1]: Entering directory '/tmp/linux/tools/lib/bpf' Auto-detecting system features: ... libelf: [ on ] ... bpf: [ on ] Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs = from latest version at 'include/uapi/linux/if_link.h' CC /tmp/bpftool/libbpf.o CC /tmp/bpftool/bpf.o CC /tmp/bpftool/nlattr.o CC /tmp/bpftool/btf.o CC /tmp/bpftool/libbpf_errno.o LD /tmp/bpftool/libbpf-in.o LINK /tmp/bpftool/libbpf.a make[1]: Leaving directory '/tmp/linux/tools/lib/bpf' LINK /tmp/bpftool/bpftool make: Leaving directory '/tmp/linux/tools/bpf/bpftool'