* [PATCH net v7] arp: Do not update neighbours from ARP in L2 multicast/broadcast frames
@ 2026-11-23 14:45 Star Chang
2026-11-24 13:46 ` Julian Anastasov
2026-11-24 14:47 ` netdev-bot+sashiko
0 siblings, 2 replies; 3+ messages in thread
From: Star Chang @ 2026-11-23 14:45 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Willem de Bruijn, Simon Horman, David Ahern, Ido Schimmel,
Julian Anastasov, Johannes Berg, Jonathan Corbet, Shuah Khan,
Randy Dunlap, netdev, linux-doc, linux-kernel, wangroger,
starchang
The drop_unicast_in_l2_multicast sysctl drops unicast IP packets that
are received in link-layer multicast or broadcast frames. On Wi-Fi this
protects against the "Hole-196" attack, where any station that knows
the group key injects frames as group-addressed traffic.
ARP is not covered. A broadcast ARP request or reply with sip set to
the gateway address and sha set to the attacker MAC still creates or
updates the gateway neighbour entry, so the attacker can poison the
ARP cache of other stations. ARP requests are legitimately broadcast
and cannot be dropped, and drop_gratuitous_arp only catches sip == tip.
This was found in an internal security review and reproduced in a lab
on a WPA2-PSK network: a group-addressed ARP reply injected by another
station changed the victim's gateway neighbour entry to the attacker
MAC. There are no kernel messages, only the wrong neighbour entry.
When drop_unicast_in_l2_multicast is set, do not pass ARP packets
received in L2 multicast/broadcast frames to neigh_event_ns() or
neigh_update(), so they can neither create nor change neighbour
entries. Requests for local and proxied addresses are still answered;
neighbours are learned from unicast replies to our own requests.
Fixes: 12b74dfadb5a ("ipv4: add option to drop unicast encapsulated in L2 multicast")
Suggested-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Star Chang <starchang@google.com>
---
v7:
- Rebase on net, arp_process() changed (Julian)
- Add an empty line before out_free_skb (Julian)
- Mention how the issue was found in the commit message
v6: https://lore.kernel.org/netdev/20261123063608.3665186-1-starchang@google.com/
- Instead of dropping L2 BMC ARP replies, skip neigh_event_ns() and
neigh_update() for any ARP received in L2 BMC frames, which also
covers broadcast requests with sip = gateway (Julian)
- Drop the frame and release reply_dst on that path (Julian)
v5: https://lore.kernel.org/netdev/20261030031136.607720-1-starchang@google.com/
v4: https://lore.kernel.org/netdev/20261027015619.1745984-1-starchang@google.com/
v3: https://lore.kernel.org/netdev/20261026150539.1357037-1-starchang@google.com/
Documentation/networking/ip-sysctl.rst | 4 ++-
net/ipv4/arp.c | 39 +++++++++++++++++++-------
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
index d3523c9064a2..fd2ffb2d2812 100644
--- a/Documentation/networking/ip-sysctl.rst
+++ b/Documentation/networking/ip-sysctl.rst
@@ -2302,7 +2302,9 @@ promote_secondaries - BOOLEAN
drop_unicast_in_l2_multicast - BOOLEAN
Drop any unicast IP packets that are received in link-layer
- multicast (or broadcast) frames.
+ multicast (or broadcast) frames. ARP packets received in such
+ frames are not used to create or update neighbour entries,
+ but ARP requests for local addresses are still answered.
This behavior (for multicast) is actually a SHOULD in RFC
1122, but is disabled by default for compatibility reasons.
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 3bc8db6ccd68..cc69ea07fc2d 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -715,6 +715,7 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
struct neighbour *n;
struct arphdr *arp;
struct rtable *rt;
+ bool bmc_no_learn;
__be32 sip, tip;
int addr_type;
@@ -794,6 +795,10 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
(!IN_DEV_ROUTE_LOCALNET(in_dev) && ipv4_is_loopback(tip)))
goto out_free_skb;
+ bmc_no_learn = (skb->pkt_type == PACKET_BROADCAST ||
+ skb->pkt_type == PACKET_MULTICAST) &&
+ IN_DEV_ORCONF(in_dev, DROP_UNICAST_IN_L2_MULTICAST);
+
/*
* For some 802.11 wireless deployments (and possibly other networks),
* there will be an ARP proxy and gratuitous ARP frames are attacks
@@ -853,14 +858,19 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
if (!dont_send && IN_DEV_ARPFILTER(in_dev))
dont_send = arp_filter(sip, tip, dev);
if (!dont_send) {
- n = neigh_event_ns(tbl, sha, &sip, dev);
- if (n) {
- arp_send_dst(ARPOP_REPLY, ETH_P_ARP,
- sip, dev, tip, sha,
- dev->dev_addr, sha,
- reply_dst);
- neigh_release(n);
+ n = NULL;
+ /* Do not learn the sender from a BMC frame */
+ if (!bmc_no_learn) {
+ n = neigh_event_ns(tbl, sha, &sip, dev);
+ if (!n)
+ goto out_consume_skb;
}
+ arp_send_dst(ARPOP_REPLY, ETH_P_ARP,
+ sip, dev, tip, sha,
+ dev->dev_addr, sha,
+ reply_dst);
+ if (n)
+ neigh_release(n);
}
goto out_consume_skb;
} else if (IN_DEV_FORWARD(in_dev)) {
@@ -869,9 +879,11 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
arp_fwd_pvlan(in_dev, dev, rt, sip, tip) ||
(rt->dst.dev != dev &&
pneigh_lookup(tbl, &tip, dev)))) {
- n = neigh_event_ns(tbl, sha, &sip, dev);
- if (n)
- neigh_release(n);
+ if (!bmc_no_learn) {
+ n = neigh_event_ns(tbl, sha, &sip, dev);
+ if (n)
+ neigh_release(n);
+ }
if (NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED ||
skb->pkt_type == PACKET_HOST ||
@@ -890,6 +902,10 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
}
}
+ /* ARP received in L2 BMC frames must not change the neighbour table */
+ if (bmc_no_learn)
+ goto out_drop_dst;
+
/* Update our ARP tables */
n = ipv4_neigh_lookup(dev, &sip);
@@ -953,6 +969,9 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
dst_release(reply_dst);
return NET_RX_SUCCESS;
+out_drop_dst:
+ dst_release(reply_dst);
+
out_free_skb:
kfree_skb(skb);
return NET_RX_DROP;
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net v7] arp: Do not update neighbours from ARP in L2 multicast/broadcast frames
2026-11-23 14:45 [PATCH net v7] arp: Do not update neighbours from ARP in L2 multicast/broadcast frames Star Chang
@ 2026-11-24 13:46 ` Julian Anastasov
2026-11-24 14:47 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: Julian Anastasov @ 2026-11-24 13:46 UTC (permalink / raw)
To: Star Chang
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Willem de Bruijn, Simon Horman, David Ahern, Ido Schimmel,
Johannes Berg, Jonathan Corbet, Shuah Khan, Randy Dunlap, netdev,
linux-doc, linux-kernel, wangroger
Hello,
On Mon, 23 Nov 2026, Star Chang wrote:
> The drop_unicast_in_l2_multicast sysctl drops unicast IP packets that
> are received in link-layer multicast or broadcast frames. On Wi-Fi this
> protects against the "Hole-196" attack, where any station that knows
> the group key injects frames as group-addressed traffic.
>
> ARP is not covered. A broadcast ARP request or reply with sip set to
> the gateway address and sha set to the attacker MAC still creates or
> updates the gateway neighbour entry, so the attacker can poison the
> ARP cache of other stations. ARP requests are legitimately broadcast
> and cannot be dropped, and drop_gratuitous_arp only catches sip == tip.
>
> This was found in an internal security review and reproduced in a lab
> on a WPA2-PSK network: a group-addressed ARP reply injected by another
> station changed the victim's gateway neighbour entry to the attacker
> MAC. There are no kernel messages, only the wrong neighbour entry.
>
> When drop_unicast_in_l2_multicast is set, do not pass ARP packets
> received in L2 multicast/broadcast frames to neigh_event_ns() or
> neigh_update(), so they can neither create nor change neighbour
> entries. Requests for local and proxied addresses are still answered;
> neighbours are learned from unicast replies to our own requests.
>
> Fixes: 12b74dfadb5a ("ipv4: add option to drop unicast encapsulated in L2 multicast")
> Suggested-by: Julian Anastasov <ja@ssi.bg>
> Signed-off-by: Star Chang <starchang@google.com>
The patch looks good to me, thanks!
Reviewed-by: Julian Anastasov <ja@ssi.bg>
> ---
> v7:
> - Rebase on net, arp_process() changed (Julian)
> - Add an empty line before out_free_skb (Julian)
> - Mention how the issue was found in the commit message
> v6: https://lore.kernel.org/netdev/20261123063608.3665186-1-starchang@google.com/
> - Instead of dropping L2 BMC ARP replies, skip neigh_event_ns() and
> neigh_update() for any ARP received in L2 BMC frames, which also
> covers broadcast requests with sip = gateway (Julian)
> - Drop the frame and release reply_dst on that path (Julian)
> v5: https://lore.kernel.org/netdev/20261030031136.607720-1-starchang@google.com/
> v4: https://lore.kernel.org/netdev/20261027015619.1745984-1-starchang@google.com/
> v3: https://lore.kernel.org/netdev/20261026150539.1357037-1-starchang@google.com/
>
> Documentation/networking/ip-sysctl.rst | 4 ++-
> net/ipv4/arp.c | 39 +++++++++++++++++++-------
> 2 files changed, 32 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
> index d3523c9064a2..fd2ffb2d2812 100644
> --- a/Documentation/networking/ip-sysctl.rst
> +++ b/Documentation/networking/ip-sysctl.rst
> @@ -2302,7 +2302,9 @@ promote_secondaries - BOOLEAN
>
> drop_unicast_in_l2_multicast - BOOLEAN
> Drop any unicast IP packets that are received in link-layer
> - multicast (or broadcast) frames.
> + multicast (or broadcast) frames. ARP packets received in such
> + frames are not used to create or update neighbour entries,
> + but ARP requests for local addresses are still answered.
>
> This behavior (for multicast) is actually a SHOULD in RFC
> 1122, but is disabled by default for compatibility reasons.
> diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
> index 3bc8db6ccd68..cc69ea07fc2d 100644
> --- a/net/ipv4/arp.c
> +++ b/net/ipv4/arp.c
> @@ -715,6 +715,7 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> struct neighbour *n;
> struct arphdr *arp;
> struct rtable *rt;
> + bool bmc_no_learn;
> __be32 sip, tip;
> int addr_type;
>
> @@ -794,6 +795,10 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> (!IN_DEV_ROUTE_LOCALNET(in_dev) && ipv4_is_loopback(tip)))
> goto out_free_skb;
>
> + bmc_no_learn = (skb->pkt_type == PACKET_BROADCAST ||
> + skb->pkt_type == PACKET_MULTICAST) &&
> + IN_DEV_ORCONF(in_dev, DROP_UNICAST_IN_L2_MULTICAST);
> +
> /*
> * For some 802.11 wireless deployments (and possibly other networks),
> * there will be an ARP proxy and gratuitous ARP frames are attacks
> @@ -853,14 +858,19 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> if (!dont_send && IN_DEV_ARPFILTER(in_dev))
> dont_send = arp_filter(sip, tip, dev);
> if (!dont_send) {
> - n = neigh_event_ns(tbl, sha, &sip, dev);
> - if (n) {
> - arp_send_dst(ARPOP_REPLY, ETH_P_ARP,
> - sip, dev, tip, sha,
> - dev->dev_addr, sha,
> - reply_dst);
> - neigh_release(n);
> + n = NULL;
> + /* Do not learn the sender from a BMC frame */
> + if (!bmc_no_learn) {
> + n = neigh_event_ns(tbl, sha, &sip, dev);
> + if (!n)
> + goto out_consume_skb;
> }
> + arp_send_dst(ARPOP_REPLY, ETH_P_ARP,
> + sip, dev, tip, sha,
> + dev->dev_addr, sha,
> + reply_dst);
> + if (n)
> + neigh_release(n);
> }
> goto out_consume_skb;
> } else if (IN_DEV_FORWARD(in_dev)) {
> @@ -869,9 +879,11 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> arp_fwd_pvlan(in_dev, dev, rt, sip, tip) ||
> (rt->dst.dev != dev &&
> pneigh_lookup(tbl, &tip, dev)))) {
> - n = neigh_event_ns(tbl, sha, &sip, dev);
> - if (n)
> - neigh_release(n);
> + if (!bmc_no_learn) {
> + n = neigh_event_ns(tbl, sha, &sip, dev);
> + if (n)
> + neigh_release(n);
> + }
>
> if (NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED ||
> skb->pkt_type == PACKET_HOST ||
> @@ -890,6 +902,10 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> }
> }
>
> + /* ARP received in L2 BMC frames must not change the neighbour table */
> + if (bmc_no_learn)
> + goto out_drop_dst;
> +
> /* Update our ARP tables */
>
> n = ipv4_neigh_lookup(dev, &sip);
> @@ -953,6 +969,9 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> dst_release(reply_dst);
> return NET_RX_SUCCESS;
>
> +out_drop_dst:
> + dst_release(reply_dst);
> +
> out_free_skb:
> kfree_skb(skb);
> return NET_RX_DROP;
> --
> 2.56.1.750.gf70dc682cf-goog
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net v7] arp: Do not update neighbours from ARP in L2 multicast/broadcast frames
2026-11-23 14:45 [PATCH net v7] arp: Do not update neighbours from ARP in L2 multicast/broadcast frames Star Chang
2026-11-24 13:46 ` Julian Anastasov
@ 2026-11-24 14:47 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 14:47 UTC (permalink / raw)
To: starchang
Cc: davem, edumazet, kuba, pabeni, willemb, horms, dsahern, idosch,
ja, johannes, corbet, skhan, rdunlap, netdev, linux-doc,
linux-kernel, wangroger
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] When drop_unicast_in_l2_multicast is set, every ARP frame that
arrives as L2 broadcast/multicast and that arp_process() does not…
- [Medium] The patch reuses the existing IP-only
drop_unicast_in_l2_multicast knob to block all ARP neighbour learning…
- [Low] The documentation and in-function comments do not match the new
behaviour.
--
arp: Do not update neighbours from ARP in L2 multicast/broadcast frames
This patch extends the drop_unicast_in_l2_multicast sysctl to ARP. When
the sysctl is set, ARP packets received in link-layer broadcast or
multicast frames are no longer passed to neigh_event_ns() or
neigh_update(), so they cannot create or change neighbour entries.
Requests for local and proxied addresses are still answered.
> diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
> index d3523c9064a22..fd2ffb2d28126 100644
> --- a/Documentation/networking/ip-sysctl.rst
> +++ b/Documentation/networking/ip-sysctl.rst
> @@ -2302,7 +2302,9 @@ promote_secondaries - BOOLEAN
>
> drop_unicast_in_l2_multicast - BOOLEAN
> Drop any unicast IP packets that are received in link-layer
> - multicast (or broadcast) frames.
> + multicast (or broadcast) frames. ARP packets received in such
> + frames are not used to create or update neighbour entries,
> + but ARP requests for local addresses are still answered.
[Severity: Low]
This isn't a bug, but should this text also mention proxied addresses?
The commit message says "Requests for local and proxied addresses are
still answered". In arp_process(), the IN_DEV_FORWARD branch still handles
BMC frames when arp_fwd_proxy(), arp_fwd_pvlan() or pneigh_lookup()
matches. It either replies through arp_send_dst() or defers through
pneigh_enqueue().
Separately, the comment block above the request handling in arp_process()
still says:
* and in the case of requests for us we add the requester to the arp
* cache.
That is no longer true when bmc_no_learn is set. Could that comment be
updated too?
> diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
> index 3bc8db6ccd68e..cc69ea07fc2de 100644
> --- a/net/ipv4/arp.c
> +++ b/net/ipv4/arp.c
[ ... ]
> @@ -794,6 +795,10 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> (!IN_DEV_ROUTE_LOCALNET(in_dev) && ipv4_is_loopback(tip)))
> goto out_free_skb;
>
> + bmc_no_learn = (skb->pkt_type == PACKET_BROADCAST ||
> + skb->pkt_type == PACKET_MULTICAST) &&
> + IN_DEV_ORCONF(in_dev, DROP_UNICAST_IN_L2_MULTICAST);
> +
[ ... ]
> @@ -890,6 +902,10 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> }
> }
>
> + /* ARP received in L2 BMC frames must not change the neighbour table */
> + if (bmc_no_learn)
> + goto out_drop_dst;
> +
> /* Update our ARP tables */
>
> n = ipv4_neigh_lookup(dev, &sip);
[Severity: Medium]
Is this exit also meant to catch broadcast ARP replies and gratuitous ARP?
ARPOP_REPLY never enters the request branch. So every reply or
announcement that arrives in a BMC frame now leaves here, before the
neigh_update() block. That also skips the existing handling for broadcast
replies further down:
if (arp->ar_op != htons(ARPOP_REPLY) ||
skb->pkt_type != PACKET_HOST)
state = NUD_STALE;
neigh_update(n, sha, state,
override ? NEIGH_UPDATE_F_OVERRIDE : 0, 0);
On hosts that already have drop_unicast_in_l2_multicast enabled (commonly
Wi-Fi clients), some behaviour seems to change:
IPv4 link-local peers that broadcast their ARP replies, as RFC 3927
section 2.5 requires, would never resolve. Our INCOMPLETE entry never gets
an lladdr and goes to FAILED. Before this patch, the broadcast reply
resolved it as NUD_STALE.
Gratuitous ARP and announcements sent after an IP takeover or MAC change
are ignored. Examples are arp_notify, bonding, VRRP/keepalived failover
and VM migration. Traffic keeps going to the old MAC until NUD probing
fails.
arp_accept no longer has any effect for BMC frames on such interfaces.
This changes the semantics of an existing IP-only knob, and the patch
carries a Fixes: tag, so it will likely be backported to stable. Should
the commit message and the ip-sysctl.rst text describe these effects?
> @@ -953,6 +969,9 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> dst_release(reply_dst);
> return NET_RX_SUCCESS;
>
> +out_drop_dst:
> + dst_release(reply_dst);
> +
> out_free_skb:
> kfree_skb(skb);
> return NET_RX_DROP;
[Severity: Medium]
Should these packets be consumed instead of dropped?
With the sysctl set, every BMC ARP that arp_process() does not answer now
takes goto out_drop_dst. Ordinary broadcast who-has requests for other
hosts on the LAN are the common case. They end in kfree_skb() with
SKB_DROP_REASON_NOT_SPECIFIED and return NET_RX_DROP. Before this patch,
the same frames went through consume_skb() and returned NET_RX_SUCCESS.
Normal background ARP would then show up as unexplained drops in
drop_monitor, dropwatch and the skb:kfree_skb tracepoint.
NF_HOOK returns the okfn result, so arp_rcv() also returns NET_RX_DROP to
netif_receive_skb(). Drivers that count that return value would then
increment rx_dropped. One example is rx_default_dqrr() in dpaa_eth.c:
if (unlikely(netif_receive_skb(skb) == NET_RX_DROP)) {
percpu_stats->rx_dropped++;
arp_rcv() in the same file avoids this on purpose for ARP that it
ignores:
/* do not tweak dropwatch on an ARP we will ignore */
if (dev->flags & IFF_NOARP ||
skb->pkt_type == PACKET_OTHERHOST ||
skb->pkt_type == PACKET_LOOPBACK)
goto consumeskb;
The other users of the same sysctl, ip_rcv_finish_core() and
ip6_rcv_core(), use SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST when they
drop.
The ip-sysctl.rst text and the commit message say these ARP packets are
not used for neighbour entries. Neither says they are dropped. The v6
changelog does say "Drop the frame and release reply_dst on that path", so
the drop looks intentional.
If the drop is intended, could it at least use a specific drop reason?
Otherwise, could this path go to out_consume_skb, so the frame is consumed
and NET_RX_SUCCESS is returned?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123144535.155300-1-starchang%40google.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 14:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 14:45 [PATCH net v7] arp: Do not update neighbours from ARP in L2 multicast/broadcast frames Star Chang
2026-11-24 13:46 ` Julian Anastasov
2026-11-24 14:47 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®