Article View: linux.kernel.netdev
Article #8715Re: [PATCH] netfilter: xt_policy: add NULL check for skb_dst() in output policy match
From: Florian Westphal
Date: Thu, 29 Oct 2026 22:20
Date: Thu, 29 Oct 2026 22:20
68 lines
9504 bytes
9504 bytes
Florian Westphal <fw@strlen.de> wrote:
[ CC Nik ]
> netdev-bot+sashiko@kernel.org <netdev-bot+sashiko@kernel.org> wrote:
> > Is this statement accurate? There seems to be a reachable path through
> > br_netfilter on a bridge port that has vlan_tunnel enabled.
> >
> > net/bridge/br_vlan_tunnel.c:br_handle_egress_vlan_tunnel() {
> > ...
> > tunnel_id = READ_ONCE(vlan->tinfo.tunnel_id);
> > if (!tunnel_id || unlikely(!skb_vlan_tag_present(skb)))
> > return 0;
> >
> > skb_dst_drop(skb);
> > ...
> > tunnel_dst = rcu_dereference(vlan->tinfo.tunnel_dst);
> > if (tunnel_dst && dst_hold_safe(&tunnel_dst->dst))
> > skb_dst_set(skb, &tunnel_dst->dst);
> >
> > return 0;
> > }
Hmm, Nik can you please have a look? Its strange that we don't return
an error. dst was dropped, tunnel dst disappeared, hwaccel tag was
cleared.
Should this return 0 only if skb_dst_set() was called?
Afaics then callers would toss the skb and we won't pass this
to inet netfilter hooks.
The original code had an unconditional skb_dst_set(),
assuming tunnel_dst is always there.
That changed with
cfc579f9d89a ("net: bridge: fix vlan tunnel dst refcnt when egressing")
fixup.
I'll quote more from report verbatim below for context.
> > So a forwarder can read the old non-zero tunnel_id and then find
> > tunnel_dst NULL, or holding a dst that dst_hold_safe() rejects. The skb
> > then goes on like this:
> >
> > __br_forward()
> > br_handle_vlan()
> > br_handle_egress_vlan_tunnel() <- dst dropped, none attached
> > NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, ...)
> > br_nf_forward()
> > br_nf_forward_ip()
> > NF_HOOK(pf, NF_INET_FORWARD, ...)
> > ipt_do_table() / ip6t_do_table()
> > policy_mt()
> > match_policy_out() <- dst == NULL
> >
> > br_nf_post_routing() does the same for POSTROUTING, and
> > policy_mt_check_hooks() allows --dir out in both hooks.
> >
> > The trigger needs a VLAN-filtering bridge with a vlan_tunnel port,
> > bridge-nf-call-iptables (or ip6tables) enabled, a "-m policy --dir out"
> > rule in FORWARD or POSTROUTING, and a tunnel mapping delete racing with
> > forwarded traffic. Given that, the pre-patch code would oops in softirq
> > context.
> >
> > Could the commit message describe this path, so the change is not taken
> > as purely defensive?
Technical Details
Message-ID:
<auPGmOxutnhGGBdK@strlen.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353505-linux-kernel-netdev=dewy.ruReferences:
<20261026125313.14810-1-fangxy@xiaopeng.com> <179330010531.3134.10986246344071690394@kernel.org> <auOiJdDR7tkMzYAf@strlen.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353505-linux-kernel-netdev=dewy.ru From: fw@strlen.de (Florian Westphal) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] netfilter: xt_policy: add NULL check for skb_dst() in output policy match Date: Thu, 29 Oct 2026 23:20:08 +0100 Organization: Usenet Network Message-ID: <auPGmOxutnhGGBdK@strlen.de> References: <20261026125313.14810-1-fangxy@xiaopeng.com> <179330010531.3134.10986246344071690394@kernel.org> <auOiJdDR7tkMzYAf@strlen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="2110426"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:hjnOBUTMLcBx7y/oJLixiBK0qys= sha256:jl7YHe9nmzEQYpILtgcxSgiDjE0fM7kbjgaO7Xps8kI= sha1:lgT7TYKFgpyqq+QVtl8gdJvxAJs= sha256:kA+Qzf6E02oC0x35mV0vw2vh3FTahgB7ZQP/k/OE55Y= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 0B469125C7D; Fri, 30 Oct 2026 01:22:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.95 X-Spam-Status: No, score=-2.95 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Yp0lbuxYIl9h; Fri, 30 Oct 2026 01:21:58 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353505-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=strlen.de X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 0A675125C7C; Fri, 30 Oct 2026 01:21:55 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id D5BD227911; Thu, 29 Oct 2026 22:20:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793312445; b=lcl819MLI6rIWuzgIXnwDAq2eKtuApRO8j02N5YisfB1PVxufv1aglR48Y7AG5rrThxZ YK1DASKYogFwy21tBREYQ8tgHzWtQREKMaIRoSFOhQtUcI6oWvbnS3+U/aopx/MbeUXZ7 zTU1U/I2VyVWRf7g/Hvh7xPvCgzKlZdYiG24xkzaT3YOUYEh2kmXnDR9BZOlUVvcds4FC AD1sVhPJ5ipDyPzcwZiqOLYwGWNHjtAXsG3dV1qdH1gjS//F2st0/x3b7ydwmkxfRtIQ0 aWEGxQCkoNu3vk6irm1Qs5uSvylCew6W75qx/5QwDDDjnNK4+HM3PAB9kAoDWWEkNrw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793312445; h=X-Original-To:Received:DMARC-Filter:Received:Date:From:To:Cc:Subject: Message-ID:References:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=TLTZJlW3mJ9y9u/qGK0yIQVgOzybe5bLTX+4cSIfhQQ=; b=uIxv90Y1F892uQWBteMZ2qPcD0+FQdQ70QvOmVJAd0L078iwDVPo5X+3Tu4hNjHzYmdo rt/+EIeN2qcD29T7LGJHh6tV9hOaK8kz1sgfjyvM5UxsANNHrUl1x9mlDO8hTqALpGWbI 7xO/wungj3yDcy41zkKYk5bpS9fKTxEMgN5Zv9fuhO3zEmk/rcvC7ZtGZutEpAip89TOy if9ghAK9LwupKyW8pJDWHh+noS3MeDf/DND/KoW/1CeK/21W+eP/lhvAf8wZ9799f4fR8 W5zUGDqwy7PKnLW/R677EQbOAyHhWHFD+QVOb7QHHVXEx3TQ0yrp6fqbbfP8k8DY3dQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=strlen.de; spf=pass smtp.mailfrom=strlen.de; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60ABA606A31F; Thu, 29 Oct 2026 22:20:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.216.245.30 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793312419; b=PPdOzi5YtBC/gdKUemPQ+WNDuREv3IaP9OqMw74q2wIgJmScYedl1M6wUc1NgDfxVqiR t69nkjXdGpMztQdu73wQph9SitU/1eLMgeWJt0BH9p8ycW+igu5OQRpsqXOOcuPeabpC9 hTpkfAtlEtzgU52Bz+CZcPKfhXQXWd4ocnaiCOHbIn3gevqcAf4dT1OHRWAL7Ia7sMbNa E9xkdS2r34PSxNq/pzPa0jGTRkOT15PzDzgpx8BmkSW6SmFvmAYn2ez7l0kn5MaqeubJW /7MlNiZ3EQponRxN7jdJ9mYAOrNeh3FptVXNGvrh6SYgsSl4XDlzXpmhTphEspfK27Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793312419; h=DMARC-Filter:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=TLTZJlW3mJ9y9u/qGK0yIQVgOzybe5bLTX+4cSIfhQQ=; b=qjVlEJAv85pnRgrFj2s8LanvceJ1qCTrxXiWsibINgTyIroj7zyubkWNJCjKZeVUGzh2 86XGsc1OcR9V8kpETFWwKjZLtxmD/7uEb5CxMFzzdfXof5cF84uo4fAKQ2OQf6Vbj0PlU ZJLfkyqhJ1TFEzDdejZCENzXpG5EjOFMDMNhyZpcuUjusMI7jPuozSRB38/Fg+MwH0c+Z S958cE4IieSewrAfh+HAGcYZkzHbkPwEmRjIYVol9BmF21a7/qBopUtBgLdudw/Z/qFkE 9FuNH1xoqIeKDZ+xaJMxcDzYggQrfXNEi2DA+K6KH9jLTg1HWZlASbcle35PrZBRB8g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=strlen.de; spf=pass smtp.mailfrom=strlen.de; arc=none smtp.remote-ip=91.216.245.30 X-Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ECFB606A31A; Thu, 29 Oct 2026 22:20:18 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7ECFB606A31A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=strlen.de X-Received: by Chamillionaire.breakpoint.cc (Postfix, from userid 1003) id B6352609D0; Thu, 29 Oct 2026 23:20:15 +0100 (CET) X-Cc: fangxy@xiaopeng.com, pablo@netfilter.org, phil@nwl.cc, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, liuwb@xiaopeng.com, razor@blackwall.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <auOiJdDR7tkMzYAf@strlen.de>