Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753139AbbHMPLD (ORCPT ); Thu, 13 Aug 2015 11:11:03 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33752 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751517AbbHMPLB (ORCPT ); Thu, 13 Aug 2015 11:11:01 -0400 Message-ID: <1439478658.7960.10.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: [PATCH 1/1] ipv4: off-by-one in continuation handling in /proc/net/route From: Eric Dumazet To: Andy Whitcroft , Alexander Duyck Cc: "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 13 Aug 2015 08:10:58 -0700 In-Reply-To: <1439461267-10627-1-git-send-email-apw@canonical.com> References: <1439461267-10627-1-git-send-email-apw@canonical.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1781 Lines: 45 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 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 > --- > 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/