Re: [PATCH net v4] net: Fix Hole-196 vulnerability by dropping unicast ARP/IP in L2 BMC

From: Julian Anastasov

Date: Sat Nov 21 2026 - 00:11:47 EST



Hello,

On Mon, 16 Nov 2026, Star Chang wrote:

> Hi Julian,
>
> You are right, any broadcast request with sip = GW can do it, not only
> GARP, so drop_gratuitous_arp does not help here.
>
> Following your suggestion, when drop_unicast_in_l2_multicast is set, ARP
> received in L2 BMC frames skips neigh_event_ns() and neigh_update(), so
> it cannot create or change any neighbour entry. Requests for us are
> still answered. Something like:
>
> --- a/net/ipv4/arp.c
> +++ b/net/ipv4/arp.c
> @@ -714,6 +714,7 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> struct neighbour *n;
> struct dst_entry *reply_dst = NULL;
> bool is_garp = false;
> + bool bmc_no_override;
>
> /* arp_rcv below verifies the ARP header and verifies the device
> * is ARP'able.
> @@ -791,6 +792,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_override = (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
> @@ -850,14 +855,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(&arp_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_override) {
> + n = neigh_event_ns(&arp_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)) {
> @@ -866,9 +876,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(&arp_tbl, net, &tip, dev)))) {
> - n = neigh_event_ns(&arp_tbl, sha, &sip, dev);
> - if (n)
> - neigh_release(n);
> + if (!bmc_no_override) {
> + n = neigh_event_ns(&arp_tbl, sha, &sip, dev);
> + if (n)
> + neigh_release(n);
> + }
>
> if (NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED ||
> skb->pkt_type == PACKET_HOST ||
> @@ -887,6 +899,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_override)
> + goto out_consume_skb;

This deserves to be 'goto out_free_skb;' but also
dst_release(reply_dst) is needed. Or we can add 'out_drop_dst:'
before 'out_free_skb:' where we will call dst_release:

+
+out_drop_dst:
+ dst_release(reply_dst);

out_free_skb:
kfree_skb(skb);


> +
> /* Update our ARP tables */
>
> n = __neigh_lookup(&arp_tbl, &sip, dev, 0);
>
> If this looks OK I will send v6.

The main part looks good to me.

Regards

--
Julian Anastasov <ja@xxxxxx>