From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH iproute2] bpf: initialise map symbol before retrieving and comparing its type Date: Wed, 21 Nov 2018 09:38:19 -0800 Message-ID: <20181121093819.0b3213d0@xeon-e3> References: <1542677187-25432-1-git-send-email-quentin.monnet@netronome.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: David Ahern , Yonghong Song , Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org, oss-drivers@netronome.com To: Quentin Monnet Return-path: Received: from mail-pl1-f196.google.com ([209.85.214.196]:44040 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbeKVENl (ORCPT ); Wed, 21 Nov 2018 23:13:41 -0500 Received: by mail-pl1-f196.google.com with SMTP id s5-v6so6474362plq.11 for ; Wed, 21 Nov 2018 09:38:21 -0800 (PST) In-Reply-To: <1542677187-25432-1-git-send-email-quentin.monnet@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 20 Nov 2018 01:26:27 +0000 Quentin Monnet wrote: > In order to compare BPF map symbol type correctly in regard to the > latest LLVM, commit 7a04dd84a7f9 ("bpf: check map symbol type properly > with newer llvm compiler") compares map symbol type to both NOTYPE and > OBJECT. To do so, it first retrieves the type from "sym.st_info" and > stores it into a temporary variable. > > However, the type is collected from the symbol "sym" before this latter > symbol is actually updated. gelf_getsym() is called after that and > updates "sym", and when comparison with OBJECT or NOTYPE happens it is > done on the type of the symbol collected in the previous passage of the > loop (or on an uninitialised symbol on the first passage). This may > eventually break map collection from the ELF file. > > Fix this by assigning the type to the temporary variable only after the > call to gelf_getsym(). > > Fixes: 7a04dd84a7f9 ("bpf: check map symbol type properly with newer llvm compiler") > Reported-by: Ron Philip > Signed-off-by: Quentin Monnet > Reviewed-by: Jiong Wang > --- > lib/bpf.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > Applied.