Article View: linux.kernel.netdev
Article #16850[PATCH net-next 12/13] netfilter: nfnetlink_queue: make skb writable before writing NFQA_L2HDR
From: Pablo Neira Ayuso
Date: Mon, 16 Nov 2026 00:16
Date: Mon, 16 Nov 2026 00:16
44 lines
9779 bytes
9779 bytes
From: Tamaki Yanagawa <ty@000ty.net>
nfqa_parse_bridge() copies the NFQA_L2HDR attribute over the mac header
of the queued skb in place. Bridge flooding queues clones that share
their data with the copies sent to the other ports, so the rewritten
header also shows up on frames that never went through the queue, and
is changed while those may already be in transmission. Call
skb_ensure_writable() before the copy. At the bridge hooks skb->data
points to the network header, so the mac header sits in the headroom,
which skb_clone_writable() already takes into account: a write length
of zero is enough, and a clone that owns its header area (nohdr) is
left alone instead of being copied.
Fixes: 8d45ff22f1b4 ("netfilter: bridge: nf queue verdict to use NFQA_VLAN and NFQA_L2HDR")
Signed-off-by: Tamaki Yanagawa <ty@000ty.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nfnetlink_queue.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index a8aa7ad832c3..862d2a762106 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -1830,10 +1830,15 @@ static int nfqa_parse_bridge(struct nf_queue_entry *entry,
if (mac_header_len != nla_len(nfqa[NFQA_L2HDR]))
return -EINVAL;
- else if (mac_header_len > 0)
+
+ if (mac_header_len > 0) {
+ if (skb_ensure_writable(entry->skb, 0))
+ return -ENOMEM;
+
memcpy(skb_mac_header(entry->skb),
nla_data(nfqa[NFQA_L2HDR]),
mac_header_len);
+ }
}
return 0;
--
2.47.3
Technical Details
Message-ID:
<20261116001612.2806263-13-pablo@netfilter.org>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-363936-linux-kernel-netdev=dewy.ruReferences:
<20261116001612.2806263-1-pablo@netfilter.org>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-363936-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 12/13] netfilter: nfnetlink_queue: make skb writable before writing NFQA_L2HDR Date: Mon, 16 Nov 2026 01:16:11 +0100 Organization: Usenet Network Message-ID: <20261116001612.2806263-13-pablo@netfilter.org> References: <20261116001612.2806263-1-pablo@netfilter.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1941790"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gkQbXcK29SIEKQ+COi4BnFCKGpg= sha256:nUB0TEeXs1hNnWSgRkm8i8YuUSixPfrReRmmduTzQ8A= sha1:reaR+eLEQQ94O2zZ7/LsoKDmmwA= sha256:xbIO6yJORzNrxlLwcPZR10NWMFT0orT/WR1Z20xU7SM= 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 41619114AB9; Mon, 16 Nov 2026 03:17:28 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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=pass (2048-bit key) header.d=netfilter.org 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 mXS4ICaXvlqE; Mon, 16 Nov 2026 03:17:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-363936-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 593CB114ABE; Mon, 16 Nov 2026 03:17:17 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 8FA4A2EC3E; Mon, 16 Nov 2026 00:17:10 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1794788228; b=hKWxFhW4w0p3aBXLvDhdmwvA7T1oFPYj9MuTgSPuj1TrLs+ThsD2UXrX0ioFesTD2phR cW7dRB04+kWT/zYdbRnvXQrB1rk46BqUtRssgfXhxyfsJqVPLb0d6HBYH3h8XKHdfoMcj vrdRP3gQ2zpBsaXrL1MzBGh27Hm1PrrTvsp19E+sMfvMwvRdZrViwd1zyZbAyObofikXy vEr+Du07ZMbE1qlYsUEdVGnSY+OsqZn23QWRwBAtnrFX2chSvMD9jXs+bqUaXDpnBi+5g wSJS8tZS6XEC8olD04anlUBtq4+MJf1wpkViWG2WM/BJyE6Mpl7dWjXHjHgm/zhmBaQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794788228; 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; bh=IxbUfHTuIUuXNXS9yjXAUzI5jyUz4Mx8VWxJc/reIZU=; b=J4GOLwFcUQ0mehu2V53+eT8GjK3a7nZ31FBkeei/IGyWxHg0VT3gBwKLCrVUMLrqYKOK 6CqCB2Nk3qxOreCWjZ9ulCImnLt+fUXMr44nCwRXFq78L2WaI0tm7G1ucHFanyHvA5typ K7v7dHrmUBpmbXsWBN8PgxeeIf1S3soR9Zx79rkNoWcb3428IvXsIeoKYN73qT3g4dv4d n49ZeYqVAUAi9hCUQtsI3y6HsvT9YRGelG235Gc/M6i+OXjUC77GxNvWa1OxWPItZwlhH OWUcTshSjRa2Oaxa0qAoHO6D2ZzAWMPy1dgvgjNbr0n3Ss9yURNxJ8aHaMuw3nCH1oA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=ZUiOY8eh; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=fail 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 92270606A31F; Mon, 16 Nov 2026 00:17:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=ZUiOY8eh X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794788227; b=Tg4o9heZVZzJL3SZMM5m0QEtAEyh7xRN9D3S7dU1gF7YoeE1DPUz32Bx0zpvDn3VagwG 8y0tv93i6B9ccWblfbIzSko6F87hqjFWJ3W5Ht3DeCb4A45mE0jJ0lX2s0IGr8DL61Kr7 WsPFyLjO3cbXpuE+YFvYKE9hqUkXZ412xpVQlFqVN8WbYUgr/o5OKb3ZNUNYj+5b3+3aF ZgFTA1yFRJiEuyCyZvlyuP+mW/ppppj9NhmomwhepGZO8gGmUnJRp8JCQDTS9ajJvkIQl KDBkCM9hp538XBYXZW636e71nwWyBdopWuPOoHXBuuztxqWWwYq1Xl1PBXzsEGS9FOQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794788227; 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-Spam-Status:X-Spam-Checker-Version; bh=IxbUfHTuIUuXNXS9yjXAUzI5jyUz4Mx8VWxJc/reIZU=; b=AWmPcMTWZ60ee+BVC+io9/iwZ5DN47dXTviL5DofXDWh1r/NnlKLSQrGm6P57WYcEBXu 0hBuKw1c3QPuEpVUJoCxuP3ga8t07+0Q+RVoPgbW/YFZYb+Jhd6AuKcC6zw2heWHSWc9T LCWKV7jrVJZLrk2AH+4LfTxG1IPoLjUEVN+qc/PLA3ghdGIcXtAeNnDlXmluCZu96LLZc Cs1Ffh4IbsN14OymnEjva4DQM0BRSSCOlo2EmK6B2J1+ObGdduOs6dkxGh1PajIoD4i8E +pwJdOkc6wXaWLl1B4iHC99TLuy3rZmAE4NOkn3W3GsppDxmRrE/1RIjzy3oN6GV2Tg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=ZUiOY8eh; arc=none smtp.remote-ip=217.70.190.124 X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (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 79FCC606A33B; Mon, 16 Nov 2026 00:17:06 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79FCC606A33B X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1794788224; bh=IxbUfHTuIUuXNXS9yjXAUzI5jyUz4Mx8VWxJc/reIZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZUiOY8ehsVe7CNPHeX+xgqNJbaXbPCHCIO2NpS1XmdYfUfA+aTX8KGAaoXmaqWI2X P8xZEyAagkr6p3YZICk1gqDAfC8cB/M35fJZOgt2AhI8bLgMfNhk5xo3lBpg8C8UBR Glg7H2t4FOEKUyCYEUjXkvVdyUAExS9egniSAt++gaY/s0a/YrVl6hpUIh8Q6fqytD /sR2IUjoE9wAaL68Ujwzmh4ucs4TakeVXKBHhc5f3xz7SY4t6Ejjwx+quUUho0GAer N50K5gqyiyvjyDM5qTg4Jlh/yUY5xDrp82aE01Vtp8n171EKgPsVHtEVh/bJU1HLQH LS39kTSanD1eQ== X-Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 713D86008C; Mon, 16 Nov 2026 01:17:03 +0100 (CET) X-Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg X-Mailer: git-send-email 2.47.3 X-In-Reply-To: <20261116001612.2806263-1-pablo@netfilter.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