From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932071AbbHNEQn (ORCPT ); Fri, 14 Aug 2015 00:16:43 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:41328 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751589AbbHNEQm (ORCPT ); Fri, 14 Aug 2015 00:16:42 -0400 Date: Thu, 13 Aug 2015 21:16:41 -0700 (PDT) Message-Id: <20150813.211641.2238542515138447940.davem@davemloft.net> To: apw@canonical.com Cc: kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, eric.dumazet@gmail.com, alexander.duyck@gmail.com Subject: Re: [PATCH 1/1 V2] ipv4: off-by-one in continuation handling in /proc/net/route From: David Miller In-Reply-To: <1439495341-12095-1-git-send-email-apw@canonical.com> References: <1439495341-12095-1-git-send-email-apw@canonical.com> X-Mailer: Mew version 6.6 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 13 Aug 2015 21:16:42 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Whitcroft Date: Thu, 13 Aug 2015 20:49:01 +0100 > 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. > > Fixes: 8be33e955cb9 ("fib_trie: Fib walk rcu should take a tnode and key instead of a trie and a leaf") > BugLink: http://bugs.launchpad.net/bugs/1483440 > Acked-by: Alexander Duyck > Signed-off-by: Andy Whitcroft Applied and queued up for -stable, thanks.