Tony Ambardar
67a57230b4
bpf: Fix sysfs export of empty BTF section
commit e23bb04b0c upstream.
If BTF data is missing or removed from the ELF section it is still exported
via sysfs as a zero-length file:
root@OpenWrt:/# ls -l /sys/kernel/btf/vmlinux
-r--r--r-- 1 root root 0 Jul 18 02:59 /sys/kernel/btf/vmlinux
Moreover, reads from this file succeed and leak kernel data:
root@OpenWrt:/# hexdump -C /sys/kernel/btf/vmlinux|head -10
000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000cc0 00 00 00 00 00 00 00 00 00 00 00 00 80 83 b0 80 |................|
000cd0 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000ce0 00 00 00 00 00 00 00 00 00 00 00 00 57 ac 6e 9d |............W.n.|
000cf0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
002650 00 00 00 00 00 00 00 10 00 00 00 01 00 00 00 01 |................|
002660 80 82 9a c4 80 85 97 80 81 a9 51 68 00 00 00 02 |..........Qh....|
002670 80 25 44 dc 80 85 97 80 81 a9 50 24 81 ab c4 60 |.%D.......P$...`|
This situation was first observed with kernel 5.4.x, cross-compiled for a
MIPS target system. Fix by adding a sanity-check for export of zero-length
data sections.
Fixes: 341dfcf8d7 ("btf: expose BTF info through sysfs")
Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/b38db205a66238f70823039a8c531535864eaac5.1600417359.git.Tony.Ambardar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-10-14 10:32:58 +02:00
..
2019-06-17 20:20:36 -07:00
2019-05-30 11:29:53 -07:00
2019-05-30 11:29:53 -07:00
2020-04-02 15:11:01 +02:00
2020-06-30 15:36:56 -04:00
2019-10-22 11:26:09 -07:00
2020-05-02 08:48:51 +02:00
2020-06-30 15:36:56 -04:00
2019-06-05 17:36:38 +02:00
2019-06-05 17:36:38 +02:00
2020-10-01 13:17:36 +02:00
2019-06-05 17:36:38 +02:00
2020-10-01 13:18:19 +02:00
2019-05-31 16:52:56 -07:00
2019-06-22 08:59:24 -04:00
2019-08-13 16:14:15 +02:00
2019-05-30 11:29:53 -07:00
2019-05-30 11:29:53 -07:00
2020-02-28 17:22:27 +01:00
2019-05-30 11:29:53 -07:00
2019-05-30 11:29:53 -07:00
2019-05-31 16:52:56 -07:00
2019-05-31 16:52:56 -07:00
2019-12-31 16:44:09 +01:00
2020-08-07 09:34:02 +02:00
2020-10-14 10:32:58 +02:00
2020-01-23 08:22:44 +01:00
2020-05-02 08:48:46 +02:00
2019-09-25 22:14:16 +02:00