toplevel.mk: drop LD_LIBRARY_PATH overrides
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-4.1 / 096-ipv4-off-by-one-in-continuation-handling-in-proc-net.patch
1 From 25b97c016b26039982daaa2c11d83979f93b71ab Mon Sep 17 00:00:00 2001
2 From: Andy Whitcroft <apw@canonical.com>
3 Date: Thu, 13 Aug 2015 20:49:01 +0100
4 Subject: [PATCH] ipv4: off-by-one in continuation handling in /proc/net/route
5
6 When generating /proc/net/route we emit a header followed by a line for
7 each route. When a short read is performed we will restart this process
8 based on the open file descriptor. When calculating the start point we
9 fail to take into account that the 0th entry is the header. This leads
10 us to skip the first entry when doing a continuation read.
11
12 This can be easily seen with the comparison below:
13
14 while read l; do echo "$l"; done </proc/net/route >A
15 cat /proc/net/route >B
16 diff -bu A B | grep '^[+-]'
17
18 On my example machine I have approximatly 10KB of route output. There we
19 see the very first non-title element is lost in the while read case,
20 and an entry around the 8K mark in the cat case:
21
22 +wlan0 00000000 02021EAC 0003 0 0 400 00000000 0 0 0
23 -tun1 00C0AC0A 00000000 0001 0 0 950 00C0FFFF 0 0 0
24
25 Fix up the off-by-one when reaquiring position on continuation.
26
27 Fixes: 8be33e955cb9 ("fib_trie: Fib walk rcu should take a tnode and key instead of a trie and a leaf")
28 BugLink: http://bugs.launchpad.net/bugs/1483440
29 Acked-by: Alexander Duyck <alexander.h.duyck@redhat.com>
30 Signed-off-by: Andy Whitcroft <apw@canonical.com>
31 Signed-off-by: David S. Miller <davem@davemloft.net>
32 ---
33 net/ipv4/fib_trie.c | 2 +-
34 1 file changed, 1 insertion(+), 1 deletion(-)
35
36 --- a/net/ipv4/fib_trie.c
37 +++ b/net/ipv4/fib_trie.c
38 @@ -2457,7 +2457,7 @@ static struct key_vector *fib_route_get_
39 key = l->key + 1;
40 iter->pos++;
41
42 - if (pos-- <= 0)
43 + if (--pos <= 0)
44 break;
45
46 l = NULL;