OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH vz7] ms/netfilter: bridge: make ebt_snat ARP rewrite writable
@ 2026-11-09 18:35 Konstantin Khorenko
  2026-11-09 18:39 ` no-reply
  0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Khorenko @ 2026-11-09 18:35 UTC (permalink / raw)
  To: Konstantin Khorenko; +Cc: devel

From: Yiming Qian <yimingqian591@gmail.com>

The ebtables SNAT target keeps the Ethernet source address rewrite
behind skb_ensure_writable(skb, 0).  This is intentional: at the bridge
ebtables hooks the Ethernet header is addressed through
skb_mac_header()/eth_hdr(), while skb->data points at the Ethernet
payload.  Asking skb_ensure_writable() for ETH_HLEN bytes would check
the payload, not the Ethernet header, and would reintroduce the small
packet regression fixed by commit 63137bc5882a.

However, the optional ARP sender hardware address rewrite is different.
It writes through skb_store_bits() at an offset relative to skb->data:

        skb_store_bits(skb, sizeof(struct arphdr), info->mac, ETH_ALEN)

skb_header_pointer() only safely reads the ARP header; it does not make
the later sender hardware address range writable.  If that range is
still held in a nonlinear skb fragment backed by a splice-imported file
page, skb_store_bits() maps the frag page and copies the new MAC address
directly into it.

Ensure the ARP SHA range is writable before reading the ARP header and
before calling skb_store_bits().

Fixes: 63137bc5882a ("netfilter: ebtables: Fixes dropping of small packets in bridge nat")
Reported-by: Yiming Qian <yimingqian591@gmail.com>
Signed-off-by: Yiming Qian <yimingqian591@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
(cherry picked from commit 67ba971ae02514d85818fe0c32549ab4bfa3bf49)

Backport notes:
 - applies unchanged.

63137bc5882a from Fixes: is not here. It undid the ebt_snat_tg() part
of ms commit c1a831167901 ("netfilter: bridge: convert
skb_make_writable to skb_ensure_writable") in v5.3, which this tree
never had, so the function here already has skb_make_writable(skb, 0)
and the unguarded ARP sender hardware address write.

skb_ensure_writable() exists here, while the rest of the file still
uses skb_make_writable(). Both pull the requested range into the linear
area, so the ARP SHA write goes to the skb head and not to a shared
fragment page. RHEL7 kernel-3.10.0-1160.169.1.el7 carries the same
change.

CVE-2026-53266
https://virtuozzo.atlassian.net/browse/VSTOR-154194

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
CVE-2026-53266 fix for the vz7 kernel.

https://virtuozzo.atlassian.net/browse/VSTOR-154194

Assisted-by: LLM
---
 net/bridge/netfilter/ebt_snat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bridge/netfilter/ebt_snat.c b/net/bridge/netfilter/ebt_snat.c
index e56ccd060d268..266345ad45c89 100644
--- a/net/bridge/netfilter/ebt_snat.c
+++ b/net/bridge/netfilter/ebt_snat.c
@@ -30,6 +30,9 @@ ebt_snat_tg(struct sk_buff *skb, const struct xt_action_param *par)
 		const struct arphdr *ap;
 		struct arphdr _ah;
 
+		if (skb_ensure_writable(skb, sizeof(_ah) + ETH_ALEN))
+			return EBT_DROP;
+
 		ap = skb_header_pointer(skb, 0, sizeof(_ah), &_ah);
 		if (ap == NULL)
 			return EBT_DROP;

---
base-commit: 78c10c447efc7633a8e4260fe7dc33e1cb4bb4d2
change-id: 20261109-b4-prep-khorenko-vstor-154194-ebt_snat-arp-writable-d0dfafef1cd3

Best regards,
--  
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-09 18:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 18:35 [Devel] [PATCH vz7] ms/netfilter: bridge: make ebt_snat ARP rewrite writable Konstantin Khorenko
2026-11-09 18:39 ` no-reply

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox