Tony Ambardar
bc33b9bb07
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 11:55:47 +02:00
..
2020-10-14 11:55:47 +02:00
2020-07-07 13:34:11 -07:00
2020-04-07 10:43:42 -07:00
2020-07-09 20:09:28 -07:00
2020-09-03 11:29:52 +02:00
2020-08-26 11:48:59 +02:00
2020-09-17 13:55:47 +02:00
2020-09-03 11:29:44 +02:00
2020-06-11 20:04:01 +02:00
2020-05-11 00:31:38 +02:00
2020-09-23 12:59:58 +02:00
2020-06-14 01:57:21 +09:00
2020-06-21 20:47:20 -07:00
2020-08-19 08:26:06 +02:00
2020-08-21 13:15:12 +02:00
2020-08-19 08:27:02 +02:00
2020-10-07 08:02:49 +02:00
2020-03-25 11:50:48 +01:00
2020-06-09 09:39:14 -07:00
2020-03-23 18:19:06 +01:00
2020-04-06 08:58:42 -07:00
2020-07-29 12:35:36 -07:00
2020-07-29 10:00:36 -04:00
2020-04-22 15:23:10 -04:00
2020-07-29 10:00:36 -04:00
2020-05-01 12:35:21 +10:00
2020-02-04 03:05:26 +00:00
2020-06-11 15:14:36 +02:00
2020-05-15 11:44:34 -07:00
2020-06-03 13:06:42 -07:00
2020-04-15 11:21:54 +02:00
2020-05-20 14:44:21 -05:00
2020-06-09 09:39:14 -07:00
2020-04-07 10:43:42 -07:00
2020-06-26 01:05:29 +02:00
2020-06-09 09:39:14 -07:00
2020-06-06 23:42:01 +09:00
2020-06-02 10:59:11 -07:00
2020-06-08 11:05:56 -07:00
2020-05-28 10:54:15 +02:00
2020-07-08 15:59:57 -07:00
2020-03-25 10:04:01 -05:00
2020-06-10 19:14:17 -07:00
2020-06-26 00:27:36 -07:00
2020-04-10 15:36:22 -07:00
2020-10-01 17:36:33 +02:00
2020-08-21 13:14:58 +02:00
2020-04-27 02:07:40 -04:00
2020-09-03 11:29:15 +02:00
2020-08-21 13:15:01 +02:00
2020-06-02 10:59:12 -07:00
2020-06-17 00:33:12 +02:00
2020-09-17 13:55:28 +02:00
2020-06-11 15:14:36 +02:00
2020-06-03 16:27:18 -07:00
2020-08-21 13:14:55 +02:00
2020-02-04 03:05:26 +00:00
2020-05-30 10:34:03 -07:00
2020-08-26 11:48:59 +02:00
2020-05-27 11:10:05 +02:00
2020-06-04 16:14:56 +01:00
2020-09-17 13:55:30 +02:00
2020-08-19 08:27:10 +02:00
2020-06-28 17:01:20 +02:00
2020-06-11 15:15:24 +02:00
2020-06-14 11:39:31 -07:00
2020-06-08 11:05:56 -07:00
2020-08-19 08:27:10 +02:00
2020-03-30 18:06:39 -07:00
2020-04-07 21:51:27 +02:00
2020-10-14 11:55:47 +02:00
2020-02-07 15:34:12 +01:00
2020-05-09 13:57:12 +02:00
2020-06-04 19:06:24 -07:00
2020-04-27 02:07:40 -04:00
2020-05-09 13:57:12 +02:00
2020-08-26 11:49:12 +02:00
2020-06-08 11:05:56 -07:00
2020-06-17 10:57:41 -07:00