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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <94ad1c4c-cf22-dfed-4e16-455443f205aa@iogearbox.net>
Date:   Wed, 25 Jul 2018 07:35:56 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Thomas Richter <tmricht@...ux.ibm.com>, ast@...nel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     heiko.carstens@...ibm.com, brueckner@...ux.vnet.ibm.com,
        schwidefsky@...ibm.com, wangnan0@...wei.com
Subject: Re: [PATCH] perf build: Build error in libbpf with
 EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"

On 07/24/2018 05:10 PM, Thomas Richter wrote:
> commit a5b8bd47dcc57 ("bpf tools: Collect eBPF programs from their own sections")
> 
> cause a compiler error when building the perf tool in the linux-next tree.
> I compile it using a FEDORA 28 installation, my gcc compiler version:
> gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20)
> 
> The file that causes the error is tools/lib/bpf/libbpf.c
> 
> Here is the error message:
> 
> [root@...lp27] # make V=1 EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"
> [...]
> make -f /home6/tmricht/linux-next/tools/build/Makefile.build
> 	dir=./util/scripting-engines obj=libperf
> libbpf.c: In function ‘bpf_object__elf_collect’:
> libbpf.c:811:15: error: ignoring return value of ‘strerror_r’,
> 		declared with attribute warn_unused_result [-Werror=unused-result]
>      strerror_r(-err, errmsg, sizeof(errmsg));
>                ^
> cc1: all warnings being treated as errors
> mv: cannot stat './.libbpf.o.tmp': No such file or directory
> /home6/tmricht/linux-next/tools/build/Makefile.build:96: recipe for target 'libbpf.o' failed
> 
> Fix this by using strerror_r return value in pr_warning statement.
> Also fixes a possible initialization issue.
> 
> Cc: Wang Nan <wangnan0@...wei.com>
> Cc: Alexei Starovoitov <ast@...nel.org>
> Cc: Daniel Borkmann <daniel@...earbox.net>
> Signed-off-by: Thomas Richter <tmricht@...ux.ibm.com>
> ---
>  tools/lib/bpf/libbpf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 955f8eafbf41..c70785ea903c 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -808,9 +808,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
>  			if (err) {
>  				char errmsg[STRERR_BUFSIZE];
>  
> -				strerror_r(-err, errmsg, sizeof(errmsg));
>  				pr_warning("failed to alloc program %s (%s): %s",
> -					   name, obj->path, errmsg);
> +					   name, obj->path,
> +					   strerror_r(-err, errmsg, sizeof(errmsg)));

This doesn't build for me. Doing this here won't work since it uses
strerror_r() variant that returns an int (which is posix variant and
not gnu specific one that would return char *):

# make
  BUILD:   Doing 'make -j4' parallel build
  HOSTCC   fixdep.o
  HOSTLD   fixdep-in.o
  LINK     fixdep
Warning: Kernel ABI header at 'tools/arch/powerpc/include/uapi/asm/unistd.h' differs from latest version at 'arch/powerpc/include/uapi/asm/unistd.h'
Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S'

Auto-detecting system features:
...                         dwarf: [ on  ]
...            dwarf_getlocations: [ on  ]
...                         glibc: [ on  ]
...                          gtk2: [ OFF ]
...                      libaudit: [ on  ]
...                        libbfd: [ on  ]
...                        libelf: [ on  ]
...                       libnuma: [ on  ]
...        numa_num_possible_cpus: [ on  ]
...                       libperl: [ OFF ]
...                     libpython: [ OFF ]
...                      libslang: [ on  ]
...                     libcrypto: [ on  ]
...                     libunwind: [ on  ]
...            libdw-dwarf-unwind: [ on  ]
...                          zlib: [ on  ]
...                          lzma: [ on  ]
...                     get_cpuid: [ on  ]
...                           bpf: [ on  ]

Makefile.config:443: No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev
Makefile.config:610: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
Makefile.config:637: Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev
Makefile.config:669: No 'python-config' tool was found: disables Python support - please install python-devel/python-dev
Makefile.config:812: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel
  GEN      common-cmds.h
  CC       fd/array.o
  CC       event-parse.o
  PERF_VERSION = 4.18.rc5.g56801c
  CC       fs/fs.o
  LD       fd/libapi-in.o
  CC       fs/tracing_path.o
  CC       event-plugin.o
  LD       fs/libapi-in.o
  CC       cpu.o
  CC       debug.o
  CC       trace-seq.o
  CC       str_error_r.o
  LD       libapi-in.o
  CC       exec-cmd.o
  AR       libapi.a
  CC       parse-filter.o
  CC       parse-utils.o
  CC       help.o
  CC       pager.o
Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'
  CC       kbuffer-parse.o
  CC       libbpf.o
  LD       libtraceevent-in.o
  LINK     libtraceevent.a
libbpf.c: In function ‘bpf_object__elf_collect’:
libbpf.c:81:10: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
   (func)("libbpf: " fmt, ##__VA_ARGS__); \
          ^
libbpf.c:84:30: note: in expansion of macro ‘__pr’
 #define pr_warning(fmt, ...) __pr(__pr_warning, fmt, ##__VA_ARGS__)
                              ^~~~
libbpf.c:858:5: note: in expansion of macro ‘pr_warning’
     pr_warning("failed to alloc program %s (%s): %s",
     ^~~~~~~~~~
  CC       parse-options.o
  HOSTCC   pmu-events/json.o
  CC       run-command.o
  HOSTCC   pmu-events/jsmn.o
cc1: all warnings being treated as errors


>  			}
>  		} else if (sh.sh_type == SHT_REL) {
>  			void *reloc = obj->efile.reloc;
> @@ -2334,7 +2334,7 @@ bpf_perf_event_read_simple(void *mem, unsigned long size,
>  	__u64 data_tail = header->data_tail;
>  	__u64 data_head = header->data_head;
>  	void *base, *begin, *end;
> -	int ret;
> +	int ret = 0;
>  
>  	asm volatile("" ::: "memory"); /* in real code it should be smp_rmb() */
>  	if (data_head == data_tail)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ