diff options
author | Yonghong Song <yhs@fb.com> | 2020-07-22 22:51:56 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-07-26 06:16:32 +0300 |
commit | 3f9969f2c040ba2ba635b6b5a7051f404bcc634d (patch) | |
tree | faca49f0c3c4e31c5690fc99551c63c292847442 /net/ipv4 | |
parent | 86176a1821a1237ad163d312ba0f2d7598757894 (diff) | |
download | linux-3f9969f2c040ba2ba635b6b5a7051f404bcc634d.tar.xz |
bpf: Fix pos computation for bpf_iter seq_ops->start()
Currently, the pos pointer in bpf iterator map/task/task_file
seq_ops->start() is always incremented.
This is incorrect. It should be increased only if
*pos is 0 (for SEQ_START_TOKEN) since these start()
function actually returns the first real object.
If *pos is not 0, it merely found the object
based on the state in seq->private, and not really
advancing the *pos. This patch fixed this issue
by only incrementing *pos if it is 0.
Note that the old *pos calculation, although not
correct, does not affect correctness of bpf_iter
as bpf_iter seq_file->read() does not support llseek.
This patch also renamed "mid" in bpf_map iterator
seq_file private data to "map_id" for better clarity.
Fixes: 6086d29def80 ("bpf: Add bpf_map iterator")
Fixes: eaaacd23910f ("bpf: Add task and task/file iterator targets")
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200722195156.4029817-1-yhs@fb.com
Diffstat (limited to 'net/ipv4')
0 files changed, 0 insertions, 0 deletions