Yonghong Song
ce880cb825
bpf: Fix a rcu warning for bpffs map pretty-print
Running selftest
./btf_btf -p
the kernel had the following warning:
[ 51.528185] WARNING: CPU: 3 PID: 1756 at kernel/bpf/hashtab.c:717 htab_map_get_next_key+0x2eb/0x300
[ 51.529217] Modules linked in:
[ 51.529583] CPU: 3 PID: 1756 Comm: test_btf Not tainted 5.9.0-rc1+ #878
[ 51.530346] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.3-1.el7.centos 04/01/2014
[ 51.531410] RIP: 0010:htab_map_get_next_key+0x2eb/0x300
...
[ 51.542826] Call Trace:
[ 51.543119] map_seq_next+0x53/0x80
[ 51.543528] seq_read+0x263/0x400
[ 51.543932] vfs_read+0xad/0x1c0
[ 51.544311] ksys_read+0x5f/0xe0
[ 51.544689] do_syscall_64+0x33/0x40
[ 51.545116] entry_SYSCALL_64_after_hwframe+0x44/0xa9
The related source code in kernel/bpf/hashtab.c:
709 static int htab_map_get_next_key(struct bpf_map *map, void *key, void *next_key)
710 {
711 struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
712 struct hlist_nulls_head *head;
713 struct htab_elem *l, *next_l;
714 u32 hash, key_size;
715 int i = 0;
716
717 WARN_ON_ONCE(!rcu_read_lock_held());
In kernel/bpf/inode.c, bpffs map pretty print calls map->ops->map_get_next_key()
without holding a rcu_read_lock(), hence causing the above warning.
To fix the issue, just surrounding map->ops->map_get_next_key() with rcu read lock.
Fixes: a26ca7c982cb ("bpf: btf: Add pretty print support to the basic arraymap")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200916004401.146277-1-yhs@fb.com
2020-09-15 18:17:39 -07:00
..
2020-09-15 18:17:39 -07:00
2020-08-03 11:57:03 -07:00
2020-04-07 10:43:42 -07:00
2020-08-04 13:49:43 -07:00
2020-08-20 10:48:17 -07:00
2020-08-21 16:17:29 +02:00
2020-08-21 09:52:53 -07:00
2020-06-14 01:57:21 +09:00
2020-08-13 09:35:59 +02:00
2020-08-01 09:26:27 +02:00
2020-05-11 00:31:38 +02:00
2020-08-10 19:07:44 -07:00
2020-08-11 10:59:19 -07:00
2020-08-04 22:22:25 -07:00
2020-08-07 11:33:28 -07:00
2020-08-15 10:36:40 -07:00
2020-08-14 14:26:08 -07:00
2020-08-13 20:03:11 -07:00
2020-03-25 11:50:48 +01:00
2020-06-09 09:39:14 -07:00
2020-07-16 12:35:15 -07:00
2020-07-27 23:25:50 +02:00
2020-08-06 19:29:51 -07:00
2020-07-27 23:25:50 +02:00
2020-08-04 14:20:26 -07:00
2020-07-29 10:00:36 -04:00
2020-04-22 15:23:10 -04:00
2020-08-04 14:20:26 -07:00
2020-07-30 11:15:58 -07: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-08-12 10:58:01 -07:00
2020-04-15 11:21:54 +02:00
2020-05-20 14:44:21 -05:00
2019-09-25 17:51:39 -07:00
2020-08-12 10:57:59 -07:00
2020-04-07 10:43:42 -07:00
2020-08-10 19:07:44 -07:00
2019-10-06 09:11:37 -06:00
2020-08-13 21:02:12 +02: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
2019-08-29 15:10:10 +01:00
2020-07-28 13:18:01 +02:00
2020-03-25 10:04:01 -05:00
2019-12-08 14:37:36 +01:00
2019-11-12 11:35:32 +01:00
2020-08-12 10:58:02 -07:00
2020-01-08 16:32:55 +00:00
2019-09-06 23:58:44 +02:00
2020-08-15 10:38:03 -07:00
2020-01-08 16:32:55 +00:00
2020-01-08 16:32:55 +00:00
2020-08-12 10:58:01 -07:00
2020-08-07 18:29:15 -07:00
2020-08-12 10:57:59 -07:00
2020-04-27 02:07:40 -04:00
2020-08-14 19:56:56 -07:00
2020-08-14 11:07:02 -07:00
2020-06-02 10:59:12 -07:00
2020-07-08 11:14:22 +02:00
2020-07-23 17:34:18 +10:00
2020-08-12 10:58:02 -07:00
2019-08-19 21:54:16 -07:00
2020-07-19 20:14:42 +02:00
2020-08-04 15:02:07 -07:00
2020-02-04 03:05:26 +00:00
2020-01-18 13:51:39 +01:00
2020-07-01 12:09:13 +03:00
2020-07-27 14:31:12 -04:00
2020-08-21 09:52:53 -07:00
2020-05-27 11:10:05 +02:00
2019-12-25 10:41:20 +01:00
2020-08-07 11:33:25 -07:00
2020-07-14 16:29:42 -07:00
2020-08-13 09:01:38 -06:00
2020-07-22 10:22:04 +02:00
2020-08-04 13:40:35 -07:00
2020-06-24 07:48:28 -07:00
2020-08-12 10:57:59 -07:00
2020-01-17 10:19:21 +01:00
2020-08-14 19:56:56 -07:00
2020-07-19 20:14:42 +02:00
2020-01-09 16:42:29 -07:00
2020-08-24 21:11:40 -07:00
2020-08-13 09:01:38 -06:00
2019-12-04 15:18:39 +01:00
2020-06-29 12:01:45 -07:00
2019-12-18 18:07:31 +01:00
2020-04-07 21:51:27 +02:00
2020-08-12 10:57:59 -07: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-07-07 11:58:59 -05:00
2020-04-27 02:07:40 -04:00
2020-05-09 13:57:12 +02:00
2020-08-17 09:39:18 -07:00
2020-06-08 11:05:56 -07:00
2020-06-17 10:57:41 -07:00