Skip to content

Commit

Permalink
ipv6_route_seq_next should increase position index
Browse files Browse the repository at this point in the history
if seq_file .next fuction does not change position index,
read after some lseek can generate unexpected output.

https://bugzilla.kernel.org/show_bug.cgi?id=206283
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
vaverin authored and davem330 committed Jan 24, 2020
1 parent a3ea867 commit 4fc427e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions net/ipv6/ip6_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,23 +2495,20 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
struct net *net = seq_file_net(seq);
struct ipv6_route_iter *iter = seq->private;

++(*pos);
if (!v)
goto iter_table;

n = rcu_dereference_bh(((struct fib6_info *)v)->fib6_next);
if (n) {
++*pos;
if (n)
return n;
}

iter_table:
ipv6_route_check_sernum(iter);
spin_lock_bh(&iter->tbl->tb6_lock);
r = fib6_walk_continue(&iter->w);
spin_unlock_bh(&iter->tbl->tb6_lock);
if (r > 0) {
if (v)
++*pos;
return iter->w.leaf;
} else if (r < 0) {
fib6_walker_unlink(net, &iter->w);
Expand Down

0 comments on commit 4fc427e

Please sign in to comment.