Commit 24cb4717 authored by Vasily Averin's avatar Vasily Averin Committed by Greg Kroah-Hartman

ipv6_route_seq_next should increase position index

[ Upstream commit 4fc427e0 ]

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=206283Signed-off-by: default avatarVasily Averin <vvs@virtuozzo.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent e10f2f29
...@@ -2377,14 +2377,13 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -2377,14 +2377,13 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
struct net *net = seq_file_net(seq); struct net *net = seq_file_net(seq);
struct ipv6_route_iter *iter = seq->private; struct ipv6_route_iter *iter = seq->private;
++(*pos);
if (!v) if (!v)
goto iter_table; goto iter_table;
n = rcu_dereference_bh(((struct fib6_info *)v)->fib6_next); n = rcu_dereference_bh(((struct fib6_info *)v)->fib6_next);
if (n) { if (n)
++*pos;
return n; return n;
}
iter_table: iter_table:
ipv6_route_check_sernum(iter); ipv6_route_check_sernum(iter);
...@@ -2392,8 +2391,6 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -2392,8 +2391,6 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
r = fib6_walk_continue(&iter->w); r = fib6_walk_continue(&iter->w);
spin_unlock_bh(&iter->tbl->tb6_lock); spin_unlock_bh(&iter->tbl->tb6_lock);
if (r > 0) { if (r > 0) {
if (v)
++*pos;
return iter->w.leaf; return iter->w.leaf;
} else if (r < 0) { } else if (r < 0) {
fib6_walker_unlink(net, &iter->w); fib6_walker_unlink(net, &iter->w);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment