Article View: linux.kernel.netdev
Article #13384[PATCH nf-next 1/2] netfilter: bridge: refragment packets with a vlan tag moved by the bridge
From: Laveesh Bansal
Date: Mon, 09 Nov 2026 19:18
Date: Mon, 09 Nov 2026 19:18
147 lines
14714 bytes
14714 bytes
Fragmented IPv4 and IPv6 packets are dropped on a vlan filtering bridge
with bridge conntrack when the protocol of their vlan tag differs from the
vlan_protocol of the bridge, an 802.1Q tag on an 802.1ad bridge for
instance. Unfragmented traffic is not affected.
br_allowed_ingress() moves such a tag back into the packet after the
NF_BR_PRE_ROUTING hooks and sets skb->protocol to the vlan ethertype, but
bridge conntrack has already defragmented the packet by then. In
postrouting nf_ct_bridge_refrag() does not know that ethertype and drops
the packet. On CONFIG_DEBUG_NET kernels the drop also warns, which is what
syzbot reported.
Save the tag with the ethernet header, pull the tag off before fragmenting
and push it back onto each fragment in nf_ct_bridge_frag_restore(), as
br_netfilter does with its encapsulation header. A ruleset can rewrite the
tag, so check the IP version against its ethertype first.
Reported-by: syzbot+a8ba738fe2db6b4bb27f@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=a8ba738fe2db6b4bb27f
Signed-off-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
---
include/linux/netfilter_bridge.h | 4 +-
net/bridge/netfilter/nf_conntrack_bridge.c | 46 ++++++++++++++++++----
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index 743475ca7e9d..772f6da27237 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -3,10 +3,12 @@
#define __LINUX_BRIDGE_NETFILTER_H
#include <uapi/linux/netfilter_bridge.h>
+#include <linux/if_vlan.h>
#include <linux/skbuff.h>
struct nf_bridge_frag_data {
- char mac[ETH_HLEN];
+ char mac[ETH_HLEN + VLAN_HLEN];
+ u8 encap_len;
bool vlan_present;
u16 vlan_tci;
__be16 vlan_proto;
diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c
index 8c83dc05114b..be4a04e9c90e 100644
--- a/net/bridge/netfilter/nf_conntrack_bridge.c
+++ b/net/bridge/netfilter/nf_conntrack_bridge.c
@@ -326,8 +326,10 @@ static unsigned int nf_ct_bridge_in(void *priv, struct sk_buff *skb,
}
static void nf_ct_bridge_frag_save(struct sk_buff *skb,
- struct nf_bridge_frag_data *data)
+ struct nf_bridge_frag_data *data,
+ unsigned int encap_len)
{
+ data->encap_len = encap_len;
if (skb_vlan_tag_present(skb)) {
data->vlan_present = true;
data->vlan_tci = skb->vlan_tci;
@@ -335,7 +337,8 @@ static void nf_ct_bridge_frag_save(struct sk_buff *skb,
} else {
data->vlan_present = false;
}
- skb_copy_from_linear_data_offset(skb, -ETH_HLEN, data->mac, ETH_HLEN);
+ skb_copy_from_linear_data_offset(skb, -ETH_HLEN, data->mac,
+ ETH_HLEN + encap_len);
}
static unsigned int
@@ -345,12 +348,38 @@ nf_ct_bridge_refrag(struct sk_buff *skb, const struct nf_hook_state *state,
struct sk_buff *))
{
struct nf_bridge_frag_data data;
+ __be16 proto = skb->protocol;
+ unsigned int encap_len = 0;
if (!BR_INPUT_SKB_CB(skb)->frag_max_size)
return NF_ACCEPT;
- nf_ct_bridge_frag_save(skb, &data);
- switch (skb->protocol) {
+ /* A vlan filtering bridge moves a vlan tag into the packet if its
+ * protocol differs from the bridge vlan_protocol, after prerouting
+ * defragmented the packet. Look past that tag.
+ */
+ if (eth_type_vlan(proto)) {
+ const struct vlan_hdr *vhdr;
+
+ if (skb_network_offset(skb) != VLAN_HLEN) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return NF_DROP;
+ }
+
+ vhdr = (const struct vlan_hdr *)skb->data;
+ encap_len = VLAN_HLEN;
+ proto = vhdr->h_vlan_encapsulated_proto;
+
+ /* A ruleset can rewrite the tag, make sure it still matches */
+ if ((proto == htons(ETH_P_IP) && ip_hdr(skb)->version != 4) ||
+ (proto == htons(ETH_P_IPV6) && ipv6_hdr(skb)->version != 6))
+ return NF_DROP;
+ }
+
+ nf_ct_bridge_frag_save(skb, &data, encap_len);
+ __skb_pull(skb, encap_len);
+
+ switch (proto) {
case htons(ETH_P_IP):
nf_br_ip_fragment(state->net, state->sk, skb, &data, output);
break;
@@ -358,20 +387,19 @@ nf_ct_bridge_refrag(struct sk_buff *skb, const struct nf_hook_state *state,
nf_br_ip6_fragment(state->net, state->sk, skb, &data, output);
break;
default:
- DEBUG_NET_WARN_ON_ONCE(1);
+ DEBUG_NET_WARN_ON_ONCE(!encap_len);
return NF_DROP;
}
return NF_STOLEN;
}
-/* Actually only slow path refragmentation needs this. */
static int nf_ct_bridge_frag_restore(struct sk_buff *skb,
const struct nf_bridge_frag_data *data)
{
int err;
- err = skb_cow_head(skb, ETH_HLEN);
+ err = skb_cow_head(skb, ETH_HLEN + data->encap_len);
if (err) {
kfree_skb(skb);
return -ENOMEM;
@@ -381,7 +409,9 @@ static int nf_ct_bridge_frag_restore(struct sk_buff *skb,
else if (skb_vlan_tag_present(skb))
__vlan_hwaccel_clear_tag(skb);
- skb_copy_to_linear_data_offset(skb, -ETH_HLEN, data->mac, ETH_HLEN);
+ __skb_push(skb, data->encap_len);
+ skb_copy_to_linear_data_offset(skb, -ETH_HLEN, data->mac,
+ ETH_HLEN + data->encap_len);
skb_reset_mac_header(skb);
return 0;
--
2.43.0
Technical Details
Message-ID:
<20261109191842.57359-2-laveeshb@laveeshbansal.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359558-linux-kernel-netdev=dewy.ruReferences:
<20261109191842.57359-1-laveeshb@laveeshbansal.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359558-linux-kernel-netdev=dewy.ru From: laveeshb@laveeshbansal.com (Laveesh Bansal) Newsgroups: linux.kernel.netdev Subject: [PATCH nf-next 1/2] netfilter: bridge: refragment packets with a vlan tag moved by the bridge Date: Mon, 9 Nov 2026 11:18:41 -0800 Organization: Usenet Network Message-ID: <20261109191842.57359-2-laveeshb@laveeshbansal.com> References: <20261109191842.57359-1-laveeshb@laveeshbansal.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="432071"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Cpfp7FMfAhgCDrz1YJs4T4YPd7c= sha256:XNxdnkNILNvMJikHwciJbmsEatDW4AnldEJ/DEHY9SQ= sha1:8xGoEr5so7DZJmu6Yvoi7UkttZs= sha256:d6cztlnKSNs6H1Fbc9XzwM5/0wsMTuqge6lfDjwAtUE= 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 0C5071138EE; Mon, 9 Nov 2026 22:24:22 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.751 X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=laveeshbansal.com 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 mZG8lq2HTz45; Mon, 9 Nov 2026 22:24:18 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-359558-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=laveeshbansal.com X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id B6C20113661; Mon, 9 Nov 2026 22:24:08 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id B3AB12C05E; Mon, 9 Nov 2026 19:20:47 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794252037; b=vWXIMQrqn/Ct3u5nEZZFKdDZbaZWEEXNO4OCF0ZhNHDVBwCA58tfLnS+m0FIBD+04lHg e+R8FbxDzfuCFsFCYzRsZ6vIqkwVZCoA4AbcxOY14Zrcc8yLIA8IgI7hGHnwER3HC+p5a Rwu/DuGmNTTWMjvW9YTGAmZcmCTrCwldwTimvlbqBLqbM1uIB0vN9bAtfAhg+J71GOnxx yRhTnIKccOFiJ8ww01Q9J8ER/+YS8iKMSEql61Ezaapd3ivgCZddkZPZ2q13E2UG8VDLg BfzZKYXDSePoz33BSp5eAJNHyS2p9jEZMpZXHTWCXlHTj3Tu3KZ8pacv7YnphzyBxyA== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794252037; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-ZohoMailClient; bh=Nhzq97sTIHN2BoJBu56XtPBI3mv0MPq/xb24cHqVV6g=; b=CW5h4eiW8yEYx/h9Vgh7M0fAOYKSwGfzfYHvFWfo6rqPhU6bFa4rMnP4wEyEI8GDr7W/ mqdasyNJCs/ybJ2mwi3KzvoXNqSXmsP8lhqNChgz/sHL/6kpDSLB8Zmrr0YkpAnSciuX8 SZgwFmj/3ZkxzDI3ovTG0fOTdz23RAgmzugc8gTGOqkU/Ujv6EWrekBJbHIgBdZczL12n j8e9bQxLLuUJdgOwrxfqDD6BvKAU9Ya4jl/mg5qtTyOdbejpx5DjiElof6oVpV609naqW 7TPeDz0hqd1RuSGOd/c9Gah4rIr1uiFeSDweuu0w/qQ/dN5jWt4AJdL9JvSN57fpUtA== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" header.d=laveeshbansal.com header.i=@laveeshbansal.com header.a=rsa-sha256 header.s=zoho header.b=Y+mYSF2U; dmarc=none header.from=laveeshbansal.com; spf=pass smtp.mailfrom=laveeshbansal.com; 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 9B34B606A330; Mon, 9 Nov 2026 19:20:37 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=laveeshbansal.com header.i=@laveeshbansal.com header.a=rsa-sha256 header.s=zoho header.b=Y+mYSF2U X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.15 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794252036; b=S1PJKh+CZ7uyUb/TfWQiG8h+1tpnWv96YtLDbOHntZZg642al4iAfyNuMMX3+L+7LRX2 Nl1Xk9nmpFYYgYUnTC1ejVbO4nWykGVOFI0sUUaZ6fAIetobs80uy3c2S5aLio8My6phq bX5/twJNXKnFgzvib1vXJGAhXLewaUiZhuoDb/RJt+YWs3WCASlEl7i5HgN/mvqDwEl3s /8X7P7QlhRLvZ5bRFnBLxFlW6ER/5rGPq7KGnl0VjlgmDmT0uTnzica/RqQeMxRSZikul 4pgiESnApIq3xaCSM9l+JdznLZMn4U3Undii0PiHHEbXyH4rmftrYQeWVoEnxqjfPCw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794252036; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-ZohoMailClient; bh=Nhzq97sTIHN2BoJBu56XtPBI3mv0MPq/xb24cHqVV6g=; b=hHByca/vixwhZa+WS4XmEbgBfZHX+TgqkWe0MxQrFnVhx7VQQpBsQyO6/rQMgFk9fUtW qmFi+1C4taiIDSBqNEVc6BX/OSZOhLmLf9XepI2vxQ1AYGLb24J+eVU5czaIgSFmrpb7s 4Ot2P4bzJZ7FYR7Gdlqychvy6SVn7mZHJ+ARRCz2K1u5KN718XEYT76dFGxnnC1QMGpM3 wDDmcJGy4ZBlLi+RyOhSuImClfywiLED0rETJB4u6Ft+ORizQpX1PJcz0NbTfoZbgE3uG KatFjWTvqduYvvBkAQ1ue9zwebMzfyx993qt78T7BTidfq+DQbL47nw++eWerqJh29g== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=laveeshbansal.com; spf=pass smtp.mailfrom=laveeshbansal.com; dkim=pass header.d=laveeshbansal.com header.i=@laveeshbansal.com header.a=rsa-sha256 header.s=zoho header.b=Y+mYSF2U; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.15 X-Received: from sender5-op-o15.zoho.com (sender5-op-o15.zoho.com [165.173.182.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 656F960A2604; Mon, 9 Nov 2026 19:20:36 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 656F960A2604 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=laveeshbansal.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=laveeshbansal.com X-ARC-Seal: i=1; a=rsa-sha256; t=1794252013; cv=none; d=zohomail.com; s=zohoarc; b=fKji/bUVi/MFPeTIh2ae8l981xMMXy1zZfjKYTusbXoJxsc9SpLPcRANoRwuq5I128Pf+xiFCBHUavytj88B8EZisnUER1ld1O6YTXmZ9h5XthPkACa8elGdfZJjXDCgOG+JxzFwvhoTP46qHlRFpjR0rkuyvIf03dMcjzTJaW0= X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794252013; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=Nhzq97sTIHN2BoJBu56XtPBI3mv0MPq/xb24cHqVV6g=; b=mako8I1mdwlo7TWPcJQsoIwsJ42v9fnTHWHm5BqTT9W41b4FDvuXNtBf7eucqgSF1wns4gV3kGeWlG2VgJo2CNA2OM5xUwB7gRKRuUTNeqDgYqxiJquQ6rWlWJ1q+T2IK0AMPY67AoHAjfUdR0oax1gP+0FrLFL6guf7oopKsJc= X-ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=laveeshbansal.com; spf=pass smtp.mailfrom=laveeshb@laveeshbansal.com; dmarc=pass header.from=<laveeshb@laveeshbansal.com> X-DKIM-Signature: a=rsa-sha256; b=Y+mYSF2UpdPAEuwHpfZTReZl0ZdymqnqX9CaQLR9L8Uq00MH/HeSgUBMTJqlP6blskQm7mRu5I/cl+w159+SsCkLi01HwT1kN88ivPW73/OmeTQHTl6gB0GalNaF1fW+IRcKR5gLJsAG4XhLRBLlRThCkHT5SRn+fP1zj+d0SSM=; c=relaxed/relaxed; s=zoho; d=laveeshbansal.com; v=1; bh=Nhzq97sTIHN2BoJBu56XtPBI3mv0MPq/xb24cHqVV6g=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; X-Received: by smtp.zohomail.com with SMTPS id 1794252012567274.2306335321746; Mon, 9 Nov 2026 11:20:12 -0800 (PST) X-Cc: Nikolay Aleksandrov <razor@blackwall.org>, Ido Schimmel <idosch@nvidia.com>, syzbot+a8ba738fe2db6b4bb27f@syzkaller.appspotmail.com, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux.dev, netdev@vger.kernel.org X-Mailer: git-send-email 2.54.0 X-In-Reply-To: <20261109191842.57359-1-laveeshb@laveeshbansal.com> 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-ZohoMailClient: External