]> git.ipfire.org Git - thirdparty/iproute2.git/commit
bpf: initialise map symbol before retrieving and comparing its type
authorQuentin Monnet <quentin.monnet@netronome.com>
Tue, 20 Nov 2018 01:26:27 +0000 (01:26 +0000)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 21 Nov 2018 17:36:30 +0000 (09:36 -0800)
commit1a7d3ad8a5862ca9ce9dd19326faeea77e5e6142
treedcb4560cce2fca624e0cb302be0fc77f887f05cf
parentebe3ce2fcc5ff3f00aa63122e9e1d5482ccbf6c9
bpf: initialise map symbol before retrieving and comparing its type

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 <ron.philip@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jiong Wang <jiong.wang@netronome.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/bpf.c