Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1206690 > unrolled thread

[PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route

Started byAndy Whitcroft <apw@canonical.com>
First post2015-08-13 12:30 +0200
Last post2015-08-13 18:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route Andy Whitcroft <apw@canonical.com> - 2015-08-13 12:30 +0200
    Re: [PATCH 1/1] ipv4: off-by-one in continuation handling in  /proc/net/route Eric Dumazet <eric.dumazet@gmail.com> - 2015-08-13 17:20 +0200
      Re: [PATCH 1/1] ipv4: off-by-one in continuation handling in  /proc/net/route Alexander Duyck <alexander.duyck@gmail.com> - 2015-08-13 18:10 +0200

#1206690 — [PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route

FromAndy Whitcroft <apw@canonical.com>
Date2015-08-13 12:30 +0200
Subject[PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route
Message-ID<pWXVN-uO-41@gated-at.bofh.it>
When generating /proc/net/route we emit a header followed by a line for
each route.  When a short read is performed we will restart this process
based on the open file descriptor.  When calculating the start point we
fail to take into account that the 0th entry is the header.  This leads
us to skip the first entry when doing a continuation read.

This can be easily seen with the comparison below:

  while read l; do echo "$l"; done </proc/net/route >A
  cat /proc/net/route >B
  diff -bu A B | grep '^[+-]'

On my example machine I have approximatly 10KB of route output.  There we
see the very first non-title element is lost in the while read case,
and an entry around the 8K mark in the cat case:

  +wlan0 00000000 02021EAC 0003 0 0 400 00000000 0 0 0
  -tun1  00C0AC0A 00000000 0001 0 0 950 00C0FFFF 0 0 0

Fix up the off-by-one when reaquiring position on continuation.

BugLink: http://bugs.launchpad.net/bugs/1483440
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 net/ipv4/fib_trie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

	From code inspection I belive this was introduced by the Fixes
	below, but I have not tested this to confirm.

	Fixes: 8be33e955cb9 ("ipv4: off-by-one in continuation handling in /proc/net/route")

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 37c4bb8..b0c6258 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2465,7 +2465,7 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter,
 		key = l->key + 1;
 		iter->pos++;
 
-		if (pos-- <= 0)
+		if (--pos <= 0)
 			break;
 
 		l = NULL;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1206905 — Re: [PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route

FromEric Dumazet <eric.dumazet@gmail.com>
Date2015-08-13 17:20 +0200
SubjectRe: [PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route
Message-ID<pX2sq-74a-17@gated-at.bofh.it>
In reply to#1206690
On Thu, 2015-08-13 at 11:21 +0100, Andy Whitcroft wrote:
> When generating /proc/net/route we emit a header followed by a line for
> each route.  When a short read is performed we will restart this process
> based on the open file descriptor.  When calculating the start point we
> fail to take into account that the 0th entry is the header.  This leads
> us to skip the first entry when doing a continuation read.
> 
> This can be easily seen with the comparison below:
> 
>   while read l; do echo "$l"; done </proc/net/route >A
>   cat /proc/net/route >B
>   diff -bu A B | grep '^[+-]'
> 
> On my example machine I have approximatly 10KB of route output.  There we
> see the very first non-title element is lost in the while read case,
> and an entry around the 8K mark in the cat case:
> 
>   +wlan0 00000000 02021EAC 0003 0 0 400 00000000 0 0 0
>   -tun1  00C0AC0A 00000000 0001 0 0 950 00C0FFFF 0 0 0
> 
> Fix up the off-by-one when reaquiring position on continuation.
> 
> BugLink: http://bugs.launchpad.net/bugs/1483440
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> ---
>  net/ipv4/fib_trie.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 	From code inspection I belive this was introduced by the Fixes
> 	below, but I have not tested this to confirm.
> 
> 	Fixes: 8be33e955cb9 ("ipv4: off-by-one in continuation handling in /proc/net/route")

You probably meant

Fixes: 8be33e955cb9 ("fib_trie: Fib walk rcu should take a tnode and key instead of a trie and a leaf")

CC Alexander for review/comment


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1206937 — Re: [PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route

FromAlexander Duyck <alexander.duyck@gmail.com>
Date2015-08-13 18:10 +0200
SubjectRe: [PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route
Message-ID<pX3eP-8ec-29@gated-at.bofh.it>
In reply to#1206905
On 08/13/2015 08:10 AM, Eric Dumazet wrote:
> On Thu, 2015-08-13 at 11:21 +0100, Andy Whitcroft wrote:
>> When generating /proc/net/route we emit a header followed by a line for
>> each route.  When a short read is performed we will restart this process
>> based on the open file descriptor.  When calculating the start point we
>> fail to take into account that the 0th entry is the header.  This leads
>> us to skip the first entry when doing a continuation read.
>>
>> This can be easily seen with the comparison below:
>>
>>    while read l; do echo "$l"; done </proc/net/route >A
>>    cat /proc/net/route >B
>>    diff -bu A B | grep '^[+-]'
>>
>> On my example machine I have approximatly 10KB of route output.  There we
>> see the very first non-title element is lost in the while read case,
>> and an entry around the 8K mark in the cat case:
>>
>>    +wlan0 00000000 02021EAC 0003 0 0 400 00000000 0 0 0
>>    -tun1  00C0AC0A 00000000 0001 0 0 950 00C0FFFF 0 0 0
>>
>> Fix up the off-by-one when reaquiring position on continuation.
>>
>> BugLink: http://bugs.launchpad.net/bugs/1483440
>> Signed-off-by: Andy Whitcroft <apw@canonical.com>
>> ---
>>   net/ipv4/fib_trie.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> 	From code inspection I belive this was introduced by the Fixes
>> 	below, but I have not tested this to confirm.
>>
>> 	Fixes: 8be33e955cb9 ("ipv4: off-by-one in continuation handling in /proc/net/route")
> You probably meant
>
> Fixes: 8be33e955cb9 ("fib_trie: Fib walk rcu should take a tnode and key instead of a trie and a leaf")
>
> CC Alexander for review/comment

I agree the Fixes line needs to be updated.  Other than that the fix 
looks good.  Once you get the comment fixed feel free to add my 
acked-by.  Also you might call out that this is needed for net, and 4.1 
stable as well.

Acked-by: Alexander Duyck <alexander.h.duyck@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web