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]
Date:	Wed, 4 Feb 2015 07:29:09 +0000
From:	Dexuan Cui <decui@...rosoft.com>
To:	Vitaly Kuznetsov <vkuznets@...hat.com>,
	KY Srinivasan <kys@...rosoft.com>,
	"devel@...uxdriverproject.org" <devel@...uxdriverproject.org>
CC:	Haiyang Zhang <haiyangz@...rosoft.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Jason Wang <jasowang@...hat.com>
Subject: RE: [PATCH 4/4] hyperv: netvsc: improve protection against rescind
 offer

> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:vkuznets@...hat.com]
> Sent: Wednesday, February 4, 2015 1:01 AM
> To: KY Srinivasan; devel@...uxdriverproject.org
> Cc: Haiyang Zhang; linux-kernel@...r.kernel.org; Dexuan Cui; Jason Wang
> Subject: [PATCH 4/4] hyperv: netvsc: improve protection against rescind offer
> 
> The check added in commit c3582a2c4d0b ("hyperv: Add support for vNIC hot
> removal") is incomplete as there is no synchronization between
> vmbus_onoffer_rescind() and netvsc_send(). In case we get the offer after we
> checked out_channel->rescind and before netvsc_send() finishes its job we can
> get a crash as we'll be dealing with already freed channel.
> 
> Make netvsc_send() take additional reference to the channel with newly
> introduced vmbus_get_channel(), this guarantees we won't lose the channel.
> We
> can still get rescind while we're processing but this won't cause a crash.
> 
> Reported-by: Jason Wang <jasowang@...hat.com>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
> ---
>  drivers/net/hyperv/netvsc.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index 9f49c01..d9b13a1 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c
> @@ -763,11 +763,16 @@ int netvsc_send(struct hv_device *device,
>  	out_channel = net_device->chn_table[packet->q_idx];
>  	if (out_channel == NULL)
>  		out_channel = device->channel;
> -	packet->channel = out_channel;
> +	packet->channel = vmbus_get_channel(out_channel);
> 
> -	if (out_channel->rescind)
> +	if (!packet->channel)
>  		return -ENODEV;
> 
> +	if (out_channel->rescind) {
> +		vmbus_put_channel(out_channel);

IMO the patch doesn't resolve the real issue.
At most it prevents the channel from disappearing in netvsc_send() only,
while actually we also need to make sure the channel is not freed before the
driver runs netvsc_remove() -> rndis_filter_device_remove() -> 
	-> netvsc_device_remove() -> vmbus_close().

I suggest we add vmbus_get/put_channel() in vmbus_open/close()?

-- Dexuan

> +		return -ENODEV;
> +	}
> +
>  	if (packet->page_buf_cnt) {
>  		ret = vmbus_sendpacket_pagebuffer(out_channel,
>  						  packet->page_buf,
> @@ -810,6 +815,7 @@ int netvsc_send(struct hv_device *device,
>  			   packet, ret);
>  	}
> 
> +	vmbus_put_channel(packet->channel);
>  	return ret;
>  }
> 
> --

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ