Skip to content

Commit 90435a7

Browse files
vaverinborkmann
authored andcommitted
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: Vasily Averin <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 07fdbee commit 90435a7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/bpf/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)
196196
void *key = map_iter(m)->key;
197197
void *prev_key;
198198

199+
(*pos)++;
199200
if (map_iter(m)->done)
200201
return NULL;
201202

@@ -208,8 +209,6 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)
208209
map_iter(m)->done = true;
209210
return NULL;
210211
}
211-
212-
++(*pos);
213212
return key;
214213
}
215214

0 commit comments

Comments
 (0)