🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.bugs
Article #383

[Bug 300551] in_arpinput() sends a reply longer than m_pkthdr.len when the request mbuf arrives as a chain, which happens on if_...

#383
From: bugzilla-noreply
Date: Fri, 06 Nov 2026 08:55
181 lines
8464 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300551

            Bug ID: 300551
           Summary: in_arpinput() sends a reply longer than m_pkthdr.len
                    when the request mbuf arrives as a chain, which
                    happens on if_bridge(4) with 64-byte requests
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: DanielWeigl@gmx.at

When the IPv4 address is on an if_bridge(4) interface, ARP replies to some
clients come out 4 bytes too long: 46 bytes instead of 42 before NIC padding.
The ARP payload is 32 bytes instead of 28, with 4 trailing zero bytes. It only
happens when the incoming ARP request is 64 bytes long; some Wi-Fi access
points pad frames to 64 bytes instead of 60. With the same address on the
physical member interface (no bridge), replies to all hosts are 42 bytes.

Analysis
--------

bridge_input() in sys/net/if_bridge.c copies broadcast frames for local
delivery and realigns them:


     mc2 = m_dup(m, M_NOWAIT);
     if (mc2 != NULL) {
                /* Keep the layer3 header aligned */
                int i = min(mc2->m_pkthdr.len, max_protohdr);
                mc2 = m_copyup(mc2, i, ETHER_ALIGN);
     }

With max_protohdr at 60 and a 64-byte frame, this gives a two-mbuf chain of 60
+ 4 bytes. A 60-byte frame stays in a single mbuf.

in_arpinput() in sys/netinet/if_ether.c reuses the request mbuf for the reply
and sets only the first mbuf’s length:

    m->m_len = sizeof(*ah) + (2 * ah->ar_pln) + (2 * ah->ar_hln);
    m->m_pkthdr.len = m->m_len;

m->m_next is neither freed nor trimmed. After this, m_pkthdr.len (28) no longer
matches the chain length (32). BPF and the driver walk the whole chain, so the
4 stale bytes go out with the reply.

Captures (tcpdump -i igc1 -e -xx arp on the bridge member port; MACs
anonymised)

The client’s ARP request as seen on igc1: 64 bytes, ARP length 50.
  ffff ffff ffff 0200 0000 0001 0806 0001
  0800 0604 0001 0200 0000 0001 0a64 01a8
  0000 0000 0000 0a64 0064 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000

The reply with the IP on bridge0 (source MAC is the bridge’s generated 58:9c:fc
address): 46 bytes, ARP length 32.

  0200 0000 0001 589c fc00 0001 0806 0001
  0800 0604 0002 589c fc00 0001 0a64 0064
  0200 0000 0001 0a64 01a8 0000 0000

The reply with the IP directly on igc1, to a different client on the same
network: 42 bytes, ARP length 28.


  0200 0000 0003 7c2b e100 0002 0806 0001
  0800 0604 0002 7c2b e100 0002 0a64 0064
  0200 0000 0003 0a64 01cc

While the IP was on the bridge, replies to clients that sent normal 60-byte
requests were also 42 bytes. Only 64-byte requests produced the longer reply.



The m_dup() + m_copyup(mc2, min(len, max_protohdr), ETHER_ALIGN) block in
bridge_input() dates back to commit 7536320 (Dec 2005: "It is not safe to use
m_copypacket() here as the returned mbuf is readonly, change to m_dup and keep
the alignment on the layer3 header."). The resulting mbuf chain is valid. The
bug is that in_arpinput() assumes the ARP request fits in one mbuf when it
builds the reply in place: it sets m_len and m_pkthdr.len on the first mbuf and
leaves m_next attached. So the bridge path has probably sent these trailing
bytes for any request longer than max_protohdr since 2005.


How to reproduce
----------------

Create bridge0 with one member, for example igc1, and put an IPv4 address on
bridge0.
From another host, send a broadcast ARP request for that address, padded to 64
bytes. For example, in scapy:
sendp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=...)/Raw(b"\0"*22)).
Run tcpdump -i igc1 -e -xx arp. The reply is length 32 instead of length 28.
Suggested fix

In in_arpinput(), trim the whole chain before sending the reply instead of
setting only m_len. For example, use m_adj(m, m->m_pkthdr.len - reply_len) or
free m->m_next, so m_pkthdr.len and the chain length match.

Observed impact
---------------

A TP-Link EAP225(EU) v5 access point (MediaTek chipset, firmware 1.3.1) pads
its clients’ ARP requests to 64 bytes. With the gateway address on the bridge,
its Wi-Fi clients regularly failed to resolve the gateway after associating:

The client’s ARP stayed INCOMPLETE.
The replies left the gateway but never showed up in the access point’s own
wired-side capture.
It cleared up after about 6.5 minutes, or straight away after any bridge
reconfiguration (which sends a gratuitous ARP).
Moving the address from bridge0 to igc1 fixed it completely.

It isn’t proven that the 4 extra bytes cause the drop. The NIC pads both frames
to 60 bytes on the wire, and the source MAC also differs: the bridge’s
generated address versus the physical one. But the mismatched mbuf lengths are
a bug either way.

Other reports
-------------

Similar reports (same symptom: a BSD gateway bridge plus TP-Link or MediaTek
access points, fixed by removing the bridge)

* TP-Link community, EAP610 with a pfSense bridge; ARP replies from the
58:9c:fc bridge MAC are dropped inside the access point: 
  - https://community.tp-link.com/en/business/forum/topic/873390
  - https://community.tp-link.com/en/business/forum/topic/840380

* OpenWrt, MediaTek access point used as a plain AP behind a pfSense/OPNsense
bridge; clients lose the gateway for about 5 minutes:
  - https://github.com/openwrt/openwrt/issues/11942


* OPNsense forum, LAN bridge with similar Wi-Fi client connectivity loss, fixed
by removing the bridge: 
  - https://forum.opnsense.org/index.php?topic=32652.0
  - https://forum.opnsense.org/index.php?topic=46397.0



Ps: the bug triage and writeup was done with the help of AI, but i tried to
understand and reason the issue as good as possible - but im not very
experienced with this abstraction level of the networking stack - so please
excuse if there are some errors in the write up.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <bug-300551-227@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.szaf.org!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.szaf.org!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.bugs
Subject: [Bug 300551] in_arpinput() sends a reply longer than m_pkthdr.len
 when the request mbuf arrives as a chain, which happens on if_bridge(4) with
 64-byte requests
Date: Fri, 06 Nov 2026 08:55:05 +0000
Organization: Newsgate at muc.de e.V.
Sender: owner-freebsd-bugs@FreeBSD.org
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-300551-227@https.bugs.freebsd.org/bugzilla/>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="75289"; mail-complaints-to="news-admin@muc.de"
X-Original-To: bugs@mlmmj.nyi.freebsd.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1793955305;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=+3vbZ75nQv6mz/8GZSfNiqZw+iN0+9Sj10Z97UUYiwU=;
	b=k9zZRiZsB/4UuOBWfwzNJI3G+KbNNeO8LdfmM0Dx0DkWYA6PMvBZkX0S/74Ufi9i5yXzw6
	8Ig8e83YZztc8iuQE1niiTwa2VBRQZmCcWSXYlhBpVAOwucHWpbgNfXzXHXNH6hJpF4qmQ
	efiPIZosAjfv+RrAikOjG0SKoyVgc4VGB1gVegFHSq+wWL90zB7Fl/eDbkyzZXUxa+c9gW
	jACc8MB3hc6gcwpAvb3Vaz48Alx3y18Jf6k/eo4O2B1Ei1auGbzcmkkIqkOizsaUHc01hI
	gi1C+YxED831Ne1BQIZF/WO//C6yG5S2T0fRCfWhiM/2it7Ae0tkiUY87p5Aug==
X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
Auto-Submitted: auto-generated
Precedence: list
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes