Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp290173imm; Thu, 26 Jul 2018 19:17:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfPONsSFdwBpil82zbqpLaLVm6Tz0+BCFLgBvkgkXXMepLq7izOpktEZFfWPn5PwLn6ChhF X-Received: by 2002:a63:291:: with SMTP id 139-v6mr4167083pgc.365.1532657857462; Thu, 26 Jul 2018 19:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532657857; cv=none; d=google.com; s=arc-20160816; b=T4U0YTbSNc0WF7Ahb6cRjBztJiuw62HI+6+2v2W45J1i+AnFqNfAEbBVSmQxV8OwbV DBLtlMy+SxtyZt57xzsqeK5Jjvof6LtOeE0FSzmuW3lpUjdfwTY76yIkMEw9xgc3C3bS 1xslWIuOCuL6D/tBPj0sQi83/37T5pihfz3brAXRSmyIuZFZw4dY0+/p73+JqPRkZ0/O 8pRLve/OrRpYLOkyPrKkBZVFhgG3G7bznquP6m6GX2Gas6dwDcow+AEiHBXaOxaUo7U9 xt9XZ27Erbm4vpqxoTdiIa+wEBQoxpRkClaNS5KOYMtG/ntOXGIwtm3lErrKxp0/i36I nGXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=5NCLULPHeGA3nF1ZRkR1qyuKEUOqfVYOqSsavUb2AgE=; b=y4fgDad0AbZqNFwF7kyO4fgku5hf4TMWrP19VGZ48aP72O32iucOqO2md4EC2G6+8D GZKbHGjrpBuUYrdYi4zJYpGNt3eU4yiHJBC9bMxCT9Zf3GrxPA1oL3cqecRERKq+olG2 zBrdCtlZZt48AYag9U6BL8jFB5ksClHRR6Sk+CGg7CIbOj11YtOjeuqfrgpb3fnGaPLz 9YpyEAf97AflwKlPcNQvRQH4tTovVWx1OXZUEb581irMUp1O4tR7J/hv05Dnux9h8LAE pIFqqY4aFSr+C7jwMytF7H4PRZQjRUBh0e26WvxGJS4kdyTGSGWRbEcCAQHXQrd5uPJm 0XuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6-v6si2444788pgk.474.2018.07.26.19.17.22; Thu, 26 Jul 2018 19:17:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732129AbeG0DgG (ORCPT + 99 others); Thu, 26 Jul 2018 23:36:06 -0400 Received: from www62.your-server.de ([213.133.104.62]:39443 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731963AbeG0DgG (ORCPT ); Thu, 26 Jul 2018 23:36:06 -0400 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1fisIt-0006hY-FV; Fri, 27 Jul 2018 04:16:27 +0200 Received: from [99.0.85.34] (helo=localhost.localdomain) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1fisIt-000X4D-4a; Fri, 27 Jul 2018 04:16:27 +0200 Subject: Re: [PATCH v2] perf build: Build error in libbpf with EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2" To: Jakub Kicinski , Thomas Richter Cc: ast@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, heiko.carstens@de.ibm.com, brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, wangnan0@huawei.com References: <20180725072126.2232-1-tmricht@linux.ibm.com> <20180725184835.5d37bef4@cakuba.netronome.com> From: Daniel Borkmann Message-ID: <08b6ed57-40a4-7468-b78d-f2a2c5ab10a8@iogearbox.net> Date: Fri, 27 Jul 2018 04:16:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20180725184835.5d37bef4@cakuba.netronome.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.0/24786/Fri Jul 27 02:41:39 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/26/2018 03:48 AM, Jakub Kicinski wrote: > On Wed, 25 Jul 2018 09:21:26 +0200, Thomas Richter wrote: >> commit a5b8bd47dcc57 ("bpf tools: Collect eBPF programs from their own sections") > > Hmm.. are you sure it's not 531b014e7a2f ("tools: bpf: make use of > reallocarray") that caused the issue? That commit made us switch from > XSI-compliant to GNU-specific strerror_r() implementation.. > > /me checks > > Yes it looks like 531b014e7a2f~ builds just fine. > > Daniel, did you try to apply v1 to the bpf tree? Perhaps there is a > confusion about the trees here, if this is caused by my recent change > it's a bpf-next material. strerror() works, but strerror_r() seems > nicer, so perhaps we could keep it if the patch worked in bpf-next? Yeah indeed, the issue is only in bpf-next. When I compile libbpf from bpf tree with the below flags then it's all good. Agree that we should rather use strerror_r() given this is a library. >> causes 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: [...] >> @@ -2334,7 +2331,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) > > This looks like a separate issue. The ret variable should really be > enum bpf_perf_event_ret, so could you please initialize it to one of the > values of this enum? > > The uninitilized condition can only happen if (data_head != data_tail) > but at the same time (data_head % size == data_tail % size) which > should never really happen... Perhaps initializing to > LIBBPF_PERF_EVENT_ERROR would make sense? > > Or better still adding: > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index f732237610e5..fa5a25945f19 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -2289,6 +2289,8 @@ bpf_perf_event_read_simple(void *mem, unsigned long size, > > begin = base + data_tail % size; > end = base + data_head % size; > + if (being == end) > + return LIBBPF_PERF_EVENT_ERROR; Sounds good to me. > while (begin != end) { > struct perf_event_header *ehdr; >