Re: [PATCH net v7] arp: Do not update neighbours from ARP in L2 multicast/broadcast frames

From: Julian Anastasov

Date: Tue Nov 24 2026 - 08:46:40 EST



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@xxxxxx>
> Signed-off-by: Star Chang <starchang@xxxxxxxxxx>

The patch looks good to me, thanks!

Reviewed-by: Julian Anastasov <ja@xxxxxx>

> ---
> 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@xxxxxxxxxx/
> - 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@xxxxxxxxxx/
> v4: https://lore.kernel.org/netdev/20261027015619.1745984-1-starchang@xxxxxxxxxx/
> v3: https://lore.kernel.org/netdev/20261026150539.1357037-1-starchang@xxxxxxxxxx/
>
> 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@xxxxxx>