lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <05232199-2e0c-3fe5-ef85-c0013f017a69@redhat.com>
Date:   Tue, 6 Dec 2016 10:30:37 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Andy Lutomirski <luto@...nel.org>, netdev@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org,
        virtualization@...ts.linux-foundation.org,
        "Michael S . Tsirkin" <mst@...hat.com>,
        Laura Abbott <labbott@...hat.com>
Subject: Re: [PATCH] virtio-net: Fix DMA-from-the-stack in
 virtnet_set_mac_address()



On 2016年12月06日 10:10, Andy Lutomirski wrote:
> With CONFIG_VMAP_STACK=y, virtnet_set_mac_address() can be passed a
> pointer to the stack and it will OOPS.  Copy the address to the heap
> to prevent the crash.
>
> Cc: Michael S. Tsirkin <mst@...hat.com>
> Cc: Jason Wang <jasowang@...hat.com>
> Cc: Laura Abbott <labbott@...hat.com>
> Reported-by: zbyszek@...waw.pl
> Signed-off-by: Andy Lutomirski <luto@...nel.org>
> ---
>
> Very lightly tested.
>
>   drivers/net/virtio_net.c | 19 ++++++++++++++-----
>   1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7276d5a95bd0..cbf1c613c67a 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -969,12 +969,17 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
>   	struct virtnet_info *vi = netdev_priv(dev);
>   	struct virtio_device *vdev = vi->vdev;
>   	int ret;
> -	struct sockaddr *addr = p;
> +	struct sockaddr *addr;
>   	struct scatterlist sg;
>   
> -	ret = eth_prepare_mac_addr_change(dev, p);
> +	addr = kmalloc(sizeof(*addr), GFP_KERNEL);
> +	if (!addr)
> +		return -ENOMEM;
> +	memcpy(addr, p, sizeof(*addr));
> +
> +	ret = eth_prepare_mac_addr_change(dev, addr);
>   	if (ret)
> -		return ret;
> +		goto out;
>   
>   	if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR)) {
>   		sg_init_one(&sg, addr->sa_data, dev->addr_len);
> @@ -982,7 +987,8 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
>   					  VIRTIO_NET_CTRL_MAC_ADDR_SET, &sg)) {
>   			dev_warn(&vdev->dev,
>   				 "Failed to set mac address by vq command.\n");
> -			return -EINVAL;
> +			ret = -EINVAL;
> +			goto out;
>   		}
>   	} else if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC) &&
>   		   !virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
> @@ -996,8 +1002,11 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
>   	}
>   
>   	eth_commit_mac_addr_change(dev, p);
> +	ret = 0;
>   
> -	return 0;
> +out:
> +	kfree(addr);
> +	return ret;
>   }
>   
>   static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev,

Acked-by: Jason Wang <jasowang@...hat.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ