[PATCH net-next v2 8/8] net: core: Convert dev_set_mac_address_user() to use struct sockaddr_storage
Paolo Abeni
pabeni at redhat.com
Tue May 27 00:02:28 PDT 2025
On 5/21/25 10:46 PM, Kees Cook wrote:
> diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
> index fff13a8b48f1..616479e71466 100644
> --- a/net/core/dev_ioctl.c
> +++ b/net/core/dev_ioctl.c
> @@ -572,9 +572,11 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data,
> return dev_set_mtu(dev, ifr->ifr_mtu);
>
> case SIOCSIFHWADDR:
> - if (dev->addr_len > sizeof(struct sockaddr))
> + if (dev->addr_len > sizeof(ifr->ifr_hwaddr))
> return -EINVAL;
> - return dev_set_mac_address_user(dev, &ifr->ifr_hwaddr, NULL);
> + return dev_set_mac_address_user(dev,
> + (struct sockaddr_storage *)&ifr->ifr_hwaddr,
> + NULL);
Side note for a possible follow-up: the above pattern is repeated a
couple of times: IMHO consolidating it into an helper would be nice.
Also such helper could/should explicitly convert ifr->ifr_hwaddr to
sockaddr_storage and avoid the cast.
/P
More information about the Linux-nvme
mailing list