提交 90435a78 编写于 作者: V Vasily Averin 提交者: Daniel Borkmann

bpf: map_seq_next should always increase position index

If seq_file .next fuction does not change position index,
read after some lseek can generate an unexpected output.

See also: https://bugzilla.kernel.org/show_bug.cgi?id=206283

v1 -> v2: removed missed increment in end of function
Signed-off-by: NVasily Averin <vvs@virtuozzo.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/eca84fdd-c374-a154-d874-6c7b55fc3bc4@virtuozzo.com
上级 07fdbee1
...@@ -196,6 +196,7 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -196,6 +196,7 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)
void *key = map_iter(m)->key; void *key = map_iter(m)->key;
void *prev_key; void *prev_key;
(*pos)++;
if (map_iter(m)->done) if (map_iter(m)->done)
return NULL; return NULL;
...@@ -208,8 +209,6 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -208,8 +209,6 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)
map_iter(m)->done = true; map_iter(m)->done = true;
return NULL; return NULL;
} }
++(*pos);
return key; return key;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册