]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix bpffs non-array map seq_show issue
authorYonghong Song <yhs@fb.com>
Thu, 9 Aug 2018 15:55:19 +0000 (08:55 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 10 Aug 2018 18:54:07 +0000 (20:54 +0200)
commit93d6ff97ae554fe2463b0e612638e2d6c2b6e1f7
tree1ba086385540f878a93b30d2e1f0b1b478a076ca
parentcf45f5a385148b39e8d824f31b64bc9a104f5d18
bpf: fix bpffs non-array map seq_show issue

In function map_seq_next() of kernel/bpf/inode.c,
the first key will be the "0" regardless of the map type.
This works for array. But for hash type, if it happens
key "0" is in the map, the bpffs map show will miss
some items if the key "0" is not the first element of
the first bucket.

This patch fixed the issue by guaranteeing to get
the first element, if the seq_show is just started,
by passing NULL pointer key to map_get_next_key() callback.
This way, no missing elements will occur for
bpffs hash table show even if key "0" is in the map.

Fixes: 4449dfbca218a ("bpf: btf: Add pretty print support to the basic arraymap")
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/inode.c