Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp493938ybl; Tue, 28 Jan 2020 06:50:10 -0800 (PST) X-Google-Smtp-Source: APXvYqw6t6FtTgGWd3cDZgtib8azaQgvs7W95mLOQtuxCpCMTOrzZ6P1sjNZhiDSd6Plsv0lCyes X-Received: by 2002:a9d:65cb:: with SMTP id z11mr15796204oth.348.1580223010729; Tue, 28 Jan 2020 06:50:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580223010; cv=none; d=google.com; s=arc-20160816; b=hlONZP9cUvYXt8RNK711RptMTsG0/7lYjNs94iTVo9cfqvOca0jDr4wORJphysVozD aGACJsJEQQ0eUFp22jA0W2bxgGg/7fQ7BS48UTmNLnBtNWV9ED8tWjA8A1K3wB6YtMru vXWr94KOGcju9NYjzoBMo5JrUyn/H8mYdnIiwiWS4i7GSL1R1WT6smiiWj6IcGVoXXRv OzhbTQkOnKlZ1oku80/U2XJCKOlRSf9RgWmQM56iwHKSnI/gp0l83MPQvFodL9B+43RD q0h6QqbmtGaZPdX2ZCbXyRmLikv118PSrURNAW4P4InqV9e1+UBAM3kXLrYCukZY/F+E BSMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IAxR38WzE6nzd0bexa2nxMGAX2bp6Nm9yPgZtkGhgt4=; b=VJoCg10LJ3ko8ErU1LLFTp3dJ+6aIfNLI1sHDEcX0qmE3zj064rzyRuiNKIorSbCVD PoYPD+zYnDsrKQwH0LVJl6rqVk5k/8IMlh47FbhTfcWUvdETDLpF3s6JZGRvmmUEAtyq y54AwVTx91UZr7i/+EWUE/gZJ7TKFq/3hZlGvMeM01WItzPNNULelwuFC7rNIgUH5imE 7Qnxfolh5fMIk8Fj8BpstNdt0CGN+sXLean88Qoj7EwCZbprOM92QNm0CgQP7yV7TZD3 pF1w/M+aei9f2pwRsMAptjH1XLurdS3BuXRL3kv4BDBNLx14Y5DwE4jZZ8ils/8+fn5l F+CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MhVaQu6q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q19si7633698otm.221.2020.01.28.06.49.58; Tue, 28 Jan 2020 06:50:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MhVaQu6q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727311AbgA1Osh (ORCPT + 99 others); Tue, 28 Jan 2020 09:48:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:48578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgA1OCT (ORCPT ); Tue, 28 Jan 2020 09:02:19 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75097205F4; Tue, 28 Jan 2020 14:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220138; bh=3hKvNmT8nmLVI3xCpYfux5YxrqvOxqQ22wVDWQSZauo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MhVaQu6qarECxABreXgoWGBF7mxYQlBk7fJiGjThhNsrVEcDB1Kn/fEBSn5+Hwgr1 hDAY5KtzGdJte9tOQ9g+2mSC2LNZEYqccTtKmX1bIUseUhrHwd+TwZgey4kfuwu9cj Pthd7iNjW3Lkqtm4u5A0c7uEvnVpb2dfljkmc+8s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven-Haegar Koch , David Ahern , "David S. Miller" Subject: [PATCH 5.4 032/104] ipv4: Detect rollover in specific fib table dump Date: Tue, 28 Jan 2020 14:59:53 +0100 Message-Id: <20200128135821.698374819@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135817.238524998@linuxfoundation.org> References: <20200128135817.238524998@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Ahern [ Upstream commit 9827c0634e461703abf81e8cc8b7adf5da5886d0 ] Sven-Haegar reported looping on fib dumps when 255.255.255.255 route has been added to a table. The looping is caused by the key rolling over from FFFFFFFF to 0. When dumping a specific table only, we need a means to detect when the table dump is done. The key and count saved to cb args are both 0 only at the start of the table dump. If key is 0 and count > 0, then we are in the rollover case. Detect and return to avoid looping. This only affects dumps of a specific table; for dumps of all tables (the case prior to the change in the Fixes tag) inet_dump_fib moved the entry counter to the next table and reset the cb args used by fib_table_dump and fn_trie_dump_leaf, so the rollover ffffffff back to 0 did not cause looping with the dumps. Fixes: effe67926624 ("net: Enable kernel side filtering of route dumps") Reported-by: Sven-Haegar Koch Signed-off-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/fib_trie.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -2175,6 +2175,12 @@ int fib_table_dump(struct fib_table *tb, int count = cb->args[2]; t_key key = cb->args[3]; + /* First time here, count and key are both always 0. Count > 0 + * and key == 0 means the dump has wrapped around and we are done. + */ + if (count && !key) + return skb->len; + while ((l = leaf_walk_rcu(&tp, key)) != NULL) { int err;