Commit 858b4c71 authored by Patrick McHardy's avatar Patrick McHardy Committed by Greg Kroah-Hartman

[PATCH] Fix crash while reading /proc/net/route

[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>
Signed-off-by: default avatarChris Wright <chrisw@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ecf4c2e1
......@@ -919,13 +919,23 @@ static struct fib_alias *fib_get_next(struct seq_file *seq)
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)
{
void *v = NULL;
read_lock(&fib_hash_lock);
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;
}
......
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