Commit 6f53f5bd authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[IPV4]: Fix crash while reading /proc/net/route caused by stale pointers

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aa9b5b02
...@@ -919,13 +919,23 @@ static struct fib_alias *fib_get_next(struct seq_file *seq) ...@@ -919,13 +919,23 @@ static struct fib_alias *fib_get_next(struct seq_file *seq)
return fa; return fa;
} }
static struct fib_alias *fib_get_idx(struct seq_file *seq, loff_t pos)
{
struct fib_alias *fa = fib_get_first(seq);
if (fa)
while (pos && (fa = fib_get_next(seq)))
--pos;
return pos ? NULL : fa;
}
static void *fib_seq_start(struct seq_file *seq, loff_t *pos) static void *fib_seq_start(struct seq_file *seq, loff_t *pos)
{ {
void *v = NULL; void *v = NULL;
read_lock(&fib_hash_lock); read_lock(&fib_hash_lock);
if (ip_fib_main_table) if (ip_fib_main_table)
v = *pos ? fib_get_next(seq) : SEQ_START_TOKEN; v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
return v; return v;
} }
......
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