Message ID | 20240419144219.21413-2-bethany.jamison@canonical.com |
---|---|
State | New |
Headers | show |
Series | [SRU,M,1/1] arp: Prevent overflow in arp_req_get(). | expand |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 9456f5bb35e5d..0d0d725b46ad0 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1125,7 +1125,8 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev) if (neigh) { if (!(READ_ONCE(neigh->nud_state) & NUD_NOARP)) { read_lock_bh(&neigh->lock); - memcpy(r->arp_ha.sa_data, neigh->ha, dev->addr_len); + memcpy(r->arp_ha.sa_data, neigh->ha, + min(dev->addr_len, sizeof(r->arp_ha.sa_data_min))); r->arp_flags = arp_state_to_flags(neigh); read_unlock_bh(&neigh->lock); r->arp_ha.sa_family = dev->type;