Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3921891pxj; Mon, 21 Jun 2021 09:25:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpYG4KWOsovKjyOM+eOt3zxZZrDhF9cNonwhwoPIbpzzS51yjaj4kfXIwXH9DCTlU0jKY9 X-Received: by 2002:a17:906:a3d7:: with SMTP id ca23mr4337716ejb.176.1624292739125; Mon, 21 Jun 2021 09:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292739; cv=none; d=google.com; s=arc-20160816; b=MQ9OZ2LMysqsUL1X7MfjxHdnvqtjnidqrYlY9skiORMcvARy0i5Ep10GitM0xky3uV AoEelMf5a6wac0RGmU3Wl4LiKIR9s3s4MtEFE1OZo9se/ZyPdRaGE7P5saXIWLsg1zUd 7glsQkmnNkxm/WvBtTQMGdsKfElKy7VMRnNnTYIAVe+mRpxKV6F2yeWqVUU4GSg4ZxnJ 4lZgVdeZFJPZL2CNEQsyBrVx16AKHu2T7OuwYvNbLwjPFphZQ4S1IZarukXG05kzWkxA uN6T1oo4vOquTBfsqDGHulbIdH973nOvRHxILeRcLi1ROFDLAS/gG/GLxaGuNfhFR49L GONQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T3zt5az2ic57VcOuM8m5eOUl2YPvBYUOzNhXO0573YU=; b=FNN+98rpXRUrP4fA3eN87mQH0X5jUiYalGC+cfOub2rpZzZCf9LUGHOD7/QMR91Nk3 XCUtPkBShMhm/MszHoxSsTzDXHl3jz5hr9sW8EjeqzN7UfJN40VdwQZW3nT6vsyL3tx8 UwxJiSk7Kh5ucG6gtQxa+aeXq9BgT2w70E6VF7lta6+CzMWoeHmWaQ1o9jM+0/SfJ762 i7wMWGUsAMqc14kwqZf2j4hp+M/hR/SvpxQcoQwiPvFoOWsikgV5ZW3s/+Pef3Q9PxCz WPc5acVuv2185O0tze3oczUxUC/dly4IbSdxglinC5Pv8Q07UVfFlP67EJN3oaY8UyB6 Kb9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sbiMiQ+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j2si15767762eds.121.2021.06.21.09.25.17; Mon, 21 Jun 2021 09:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sbiMiQ+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231500AbhFUQ0l (ORCPT + 99 others); Mon, 21 Jun 2021 12:26:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbhFUQZG (ORCPT ); Mon, 21 Jun 2021 12:25:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 87C2F613BE; Mon, 21 Jun 2021 16:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292497; bh=KKHN1tZqk9vOiF5zfiekK61Ol5daYmg0Vt7OKUL8Xxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sbiMiQ+w5Ki/xOD7wGUaGwvStipUSW8hTGU/V61wOqVe5pABwQtkSIyCdk+xXM3x3 ySWVpEYkINokmu/39jw2dbNQ7idZq42P4OlJEhTftVMd5mrvCZlTMh9+jJUt+JEihP 14p0OmlX9HN1ebgs/6JDlchSf40aIAU2iTozfQbw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 022/146] netfilter: nft_fib_ipv6: skip ipv6 packets from any to link-local Date: Mon, 21 Jun 2021 18:14:12 +0200 Message-Id: <20210621154912.027676066@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal [ Upstream commit 12f36e9bf678a81d030ca1b693dcda62b55af7c5 ] The ip6tables rpfilter match has an extra check to skip packets with "::" source address. Extend this to ipv6 fib expression. Else ipv6 duplicate address detection packets will fail rpf route check -- lookup returns -ENETUNREACH. While at it, extend the prerouting check to also cover the ingress hook. Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1543 Fixes: f6d0cbcf09c5 ("netfilter: nf_tables: add fib expression") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/ipv6/netfilter/nft_fib_ipv6.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c index e204163c7036..92f3235fa287 100644 --- a/net/ipv6/netfilter/nft_fib_ipv6.c +++ b/net/ipv6/netfilter/nft_fib_ipv6.c @@ -135,6 +135,17 @@ void nft_fib6_eval_type(const struct nft_expr *expr, struct nft_regs *regs, } EXPORT_SYMBOL_GPL(nft_fib6_eval_type); +static bool nft_fib_v6_skip_icmpv6(const struct sk_buff *skb, u8 next, const struct ipv6hdr *iph) +{ + if (likely(next != IPPROTO_ICMPV6)) + return false; + + if (ipv6_addr_type(&iph->saddr) != IPV6_ADDR_ANY) + return false; + + return ipv6_addr_type(&iph->daddr) & IPV6_ADDR_LINKLOCAL; +} + void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, const struct nft_pktinfo *pkt) { @@ -163,10 +174,13 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, lookup_flags = nft_fib6_flowi_init(&fl6, priv, pkt, oif, iph); - if (nft_hook(pkt) == NF_INET_PRE_ROUTING && - nft_fib_is_loopback(pkt->skb, nft_in(pkt))) { - nft_fib_store_result(dest, priv, nft_in(pkt)); - return; + if (nft_hook(pkt) == NF_INET_PRE_ROUTING || + nft_hook(pkt) == NF_INET_INGRESS) { + if (nft_fib_is_loopback(pkt->skb, nft_in(pkt)) || + nft_fib_v6_skip_icmpv6(pkt->skb, pkt->tprot, iph)) { + nft_fib_store_result(dest, priv, nft_in(pkt)); + return; + } } *dest = 0; -- 2.30.2