1
0
Fork 0
alistair23-linux/samples
Jesper Dangaard Brouer 634813e41f samples/bpf: Fix broken xdp_rxq_info due to map order assumptions
commit edbca120a8 upstream.

In the days of using bpf_load.c the order in which the 'maps' sections
were defines in BPF side (*_kern.c) file, were used by userspace side
to identify the map via using the map order as an index. In effect the
order-index is created based on the order the maps sections are stored
in the ELF-object file, by the LLVM compiler.

This have also carried over in libbpf via API bpf_map__next(NULL, obj)
to extract maps in the order libbpf parsed the ELF-object file.

When BTF based maps were introduced a new section type ".maps" were
created. I found that the LLVM compiler doesn't create the ".maps"
sections in the order they are defined in the C-file. The order in the
ELF file is based on the order the map pointer is referenced in the code.

This combination of changes lead to xdp_rxq_info mixing up the map
file-descriptors in userspace, resulting in very broken behaviour, but
without warning the user.

This patch fix issue by instead using bpf_object__find_map_by_name()
to find maps via their names. (Note, this is the ELF name, which can
be longer than the name the kernel retains).

Fixes: be5bca44aa ("samples: bpf: convert some XDP samples from bpf_load to libbpf")
Fixes: 451d1dc886 ("samples: bpf: update map definition to new syntax BTF-defined map")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/157529025128.29832.5953245340679936909.stgit@firesoul
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-26 10:00:58 +01:00
..
auxdisplay auxdisplay: Fix a typo in cfag12864b-example.c 2019-08-08 20:00:18 +02:00
binderfs treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
bpf samples/bpf: Fix broken xdp_rxq_info due to map order assumptions 2020-01-26 10:00:58 +01:00
configfs treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 145 2019-05-30 11:25:18 -07:00
connector treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
hidraw HID: samples/hidraw: fix typo in printed message 2018-11-21 00:31:58 +01:00
hw_breakpoint treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
kdb treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
kfifo treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 465 2019-06-19 17:09:10 +02:00
kobject treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
kprobes treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
livepatch treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
mei samples: mei: use /dev/mei0 instead of /dev/mei 2019-01-30 15:24:45 +01:00
mic/mpssd treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 290 2019-06-05 17:36:38 +02:00
pidfd samples: make pidfd-metadata fail gracefully on older kernels 2019-06-24 15:55:50 +02:00
pktgen samples: pktgen: fix proc_cmd command result check logic 2019-12-31 16:43:45 +01:00
qmi treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
rpmsg samples/rpmsg: Introduce a module parameter for message count 2019-08-26 22:10:39 -07:00
seccomp samples/seccomp: Zero out members based on seccomp_notif_sizes 2020-01-09 10:19:57 +01:00
timers License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace_events sched/core: Provide a pointer to the valid CPU mask 2019-06-03 11:49:37 +02:00
trace_printk samples/trace_printk: Wait for IRQ work to finish 2020-01-09 10:20:00 +01:00
uhid treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
v4l media: v4l2-pci-skeleton.c: fix doc warning 2019-05-28 13:14:28 -04:00
vfio-mdev vfio-mdev/mtty: Simplify interrupt generation 2019-08-19 13:28:57 -06:00
vfs treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
watchdog License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
Makefile kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples 2019-06-15 19:57:01 +09:00