From patchwork Thu Oct 3 15:49:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175124 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp551174ill; Thu, 3 Oct 2019 09:25:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9TL7XGfyZWZMr17/0YKBjabLgvEInmjw9zkO0nBa/+e5Lt/eWBXHPANgyYyQgf6wE6fld X-Received: by 2002:a50:ab0f:: with SMTP id s15mr10403584edc.119.1570119925965; Thu, 03 Oct 2019 09:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570119925; cv=none; d=google.com; s=arc-20160816; b=HNQNVVWCZM6N5wnpOR2AXjvWCsKYNijtmayQ8hnt4nAl5VNMmOxog90QGeZWItNF7V D6kGL44pY62uAKa+ddIqx13PSGAbxBfMhsw2KHXx7r3mCRauQtGjCXuwYP0RX4SnAaxa sILzdKm9SanedbRQ8BU2jRt5cod3hQZjzHVqSckUitHwVv7OInh6KR0OYscptDoeLzmT q5f3KNXLC9gg1NR+8oUNf2dcPStJSyseLtvbf9NjK95gt8pvrEVrGJHR3+ZhghOzuATj PCp1324Xald9ZFrfdNzaJz8xLCkKXKTXhPew1hNbNjFiDv0weOY3glmi0zbD3/6fiF00 s3gQ== 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=zJBAVilOuhUqY84k6KrNyqAx3rbr/hoQIEzu98Wg9Zs=; b=hjYJ4jmcgL812I1TcEowxyKjW2lIW4TgqBZIHemW35lkusgrCwK+w92Ik2XzYTGdm7 JBu3x1ujmTbUAz1K0M5BPQiIbRXFhS62fT52siw7gfuoKh0B1I1xJrrPMArTqHDgrCGK qEcitPqRUb0NOB6qxdvSXod7xyM/CyiYOxw7f8Mch2egM8s4l8JLmhHYycVyYxikrjQh OB5lrlyd9pgCytphy4iSSTZaHAIp1fQDKH3rTkYA0ffh+ZCBKcGNYa7ATPdNbR/5jq30 pU2P+S3fAxUKospLKa/nO5PQ99OoV5DuQICrcbL//mRyVqc90til2o21e48PBhrYBA2V ke/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ndSzGgPK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 z7si1806941edb.160.2019.10.03.09.25.25; Thu, 03 Oct 2019 09:25:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=ndSzGgPK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728905AbfJCQZX (ORCPT + 14 others); Thu, 3 Oct 2019 12:25:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:55514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390494AbfJCQZW (ORCPT ); Thu, 3 Oct 2019 12:25:22 -0400 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 F020A215EA; Thu, 3 Oct 2019 16:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119920; bh=3Ns8z5rPL19etrEXv+UVIEZ1HUYcfTPW144ZHogKkn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ndSzGgPKTyea8GE1tDyU1TEhV35Og5aLIK/wWXJ+LJKNGUDkz85Q8+4lGp9rcY4Tp rQQ67FnP625PueVzb/xfuc94KF1xklmrMigunm+3VAtIywsCd7dbmK70aTt6s48Q6U kyW7r3e0NEeQNtrVv6u3YQNV/43ewA8gY9MIkjD8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" , Wei Wang , "David S. Miller" Subject: [PATCH 5.2 003/313] ipv6: do not free rt if FIB_LOOKUP_NOREF is set on suppress rule Date: Thu, 3 Oct 2019 17:49:41 +0200 Message-Id: <20191003154533.875309419@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "Jason A. Donenfeld" [ Upstream commit ca7a03c4175366a92cee0ccc4fec0038c3266e26 ] Commit 7d9e5f422150 removed references from certain dsts, but accounting for this never translated down into the fib6 suppression code. This bug was triggered by WireGuard users who use wg-quick(8), which uses the "suppress-prefix" directive to ip-rule(8) for routing all of their internet traffic without routing loops. The test case added here causes the reference underflow by causing packets to evaluate a suppress rule. Fixes: 7d9e5f422150 ("ipv6: convert major tx path to use RT6_LOOKUP_F_DST_NOREF") Signed-off-by: Jason A. Donenfeld Acked-by: Wei Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/fib6_rules.c | 3 ++- tools/testing/selftests/net/fib_tests.sh | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -285,7 +285,8 @@ static bool fib6_rule_suppress(struct fi return false; suppress_route: - ip6_rt_put(rt); + if (!(arg->flags & FIB_LOOKUP_NOREF)) + ip6_rt_put(rt); return true; } --- a/tools/testing/selftests/net/fib_tests.sh +++ b/tools/testing/selftests/net/fib_tests.sh @@ -9,7 +9,7 @@ ret=0 ksft_skip=4 # all tests in this script. Can be overridden with -t option -TESTS="unregister down carrier nexthop ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw" +TESTS="unregister down carrier nexthop suppress ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw" VERBOSE=0 PAUSE_ON_FAIL=no @@ -582,6 +582,20 @@ fib_nexthop_test() cleanup } +fib_suppress_test() +{ + $IP link add dummy1 type dummy + $IP link set dummy1 up + $IP -6 route add default dev dummy1 + $IP -6 rule add table main suppress_prefixlength 0 + ping -f -c 1000 -W 1 1234::1 || true + $IP -6 rule del table main suppress_prefixlength 0 + $IP link del dummy1 + + # If we got here without crashing, we're good. + return 0 +} + ################################################################################ # Tests on route add and replace @@ -1558,6 +1572,7 @@ do fib_down_test|down) fib_down_test;; fib_carrier_test|carrier) fib_carrier_test;; fib_nexthop_test|nexthop) fib_nexthop_test;; + fib_suppress_test|suppress) fib_suppress_test;; ipv6_route_test|ipv6_rt) ipv6_route_test;; ipv4_route_test|ipv4_rt) ipv4_route_test;; ipv6_addr_metric) ipv6_addr_metric_test;;