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] [day] [month] [year] [list]
Date:   Mon, 6 Aug 2018 11:15:40 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     "Michael S. Tsirkin" <mst@...hat.com>
Cc:     kvm@...r.kernel.org, virtualization@...ts.linux-foundation.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] vhost: switch to use new message format



On 2018年08月03日 15:59, Michael S. Tsirkin wrote:
>> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
>> index a502f1a..6f6c42d 100644
>> --- a/drivers/vhost/vhost.c
>> +++ b/drivers/vhost/vhost.c
>> @@ -315,6 +315,7 @@ static void vhost_vq_reset(struct vhost_dev *dev,
>>   	vq->log_addr = -1ull;
>>   	vq->private_data = NULL;
>>   	vq->acked_features = 0;
>> +	vq->acked_backend_features = 0;
>>   	vq->log_base = NULL;
>>   	vq->error_ctx = NULL;
>>   	vq->kick = NULL;
>> @@ -1027,28 +1028,40 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
>>   ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
>>   			     struct iov_iter *from)
>>   {
>> -	struct vhost_msg_node node;
>> -	unsigned size = sizeof(struct vhost_msg);
>> -	size_t ret;
>> -	int err;
>> +	struct vhost_iotlb_msg msg;
>> +	size_t offset;
>> +	int type, ret;
>>   
>> -	if (iov_iter_count(from) < size)
>> -		return 0;
>> -	ret = copy_from_iter(&node.msg, size, from);
>> -	if (ret != size)
>> +	ret = copy_from_iter(&type, sizeof(type), from);
>> +	if (ret != sizeof(type))
>>   		goto done;
>>   
>> -	switch (node.msg.type) {
>> +	switch (type) {
>>   	case VHOST_IOTLB_MSG:
>> -		err = vhost_process_iotlb_msg(dev, &node.msg.iotlb);
>> -		if (err)
>> -			ret = err;
>> +		/* There maybe a hole after type for V1 message type,
>> +		 * so skip it here.
>> +		 */
>> +		offset = offsetof(struct vhost_msg, iotlb) - sizeof(int);
>> +		break;
>> +	case VHOST_IOTLB_MSG_V2:
>> +		offset = sizeof(__u32);
>>   		break;
>>   	default:
>>   		ret = -EINVAL;
>> -		break;
>> +		goto done;
>> +	}
>> +
>> +	iov_iter_advance(from, offset);
>> +	ret = copy_from_iter(&msg, sizeof(msg), from);
>> +	if (ret != sizeof(msg))
>> +		goto done;
>> +	if (vhost_process_iotlb_msg(dev, &msg)) {
>> +		ret = -EFAULT;
>> +		goto done;
>>   	}
>>   
>> +	ret = (type == VHOST_IOTLB_MSG) ? sizeof(struct vhost_msg) :
>> +	      sizeof(struct vhost_msg_v2);
>>   done:
>>   	return ret;
>>   }
> We can actually fix 32 bit apps too, checking the mode for v1.
> But that can wait for another patch.
>

Yes, let me do it on top.

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ