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: <4E5A3924.4050006@gmail.com>
Date:	Sun, 28 Aug 2011 20:48:36 +0800
From:	Wang Sheng-Hui <shhuiw@...il.com>
To:	"Michael S. Tsirkin" <mst@...hat.com>
CC:	wanlong.gao@...il.com, rusty@...tcorp.com.au,
	virtualization@...ts.linux-foundation.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] virtio: fix size computation according to the definition
 of struct vring_used in vring_size

On 2011年08月28日 19:31, Michael S. Tsirkin wrote:
> On Sat, Aug 27, 2011 at 05:52:02PM +0800, Wang Sheng-Hui wrote:
>> On 2011年08月27日 17:34, Wang Sheng-Hui wrote:
>>> On 2011年08月27日 10:49, Wanlong Gao wrote:
>>>> On Sat, 2011-08-27 at 09:07 +0800, Wang Sheng-Hui wrote:
>>>>> The patch is against 3.1-rc3.
>>>>>
>>>>> struct vring_used has two __u16 fields plus array of struct vring_used_elem.
>>>>> Current vring_size counts the __u16 fields to 3. Fix it to 2 in the patch.
>>>>>
>>>>> Signed-off-by: Wang Sheng-Hui <shhuiw@...il.com>
>>>>> ---
>>>>>  include/linux/virtio_ring.h |    2 +-
>>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
>>>>> index 4a32cb6..fcda152 100644
>>>>> --- a/include/linux/virtio_ring.h
>>>>> +++ b/include/linux/virtio_ring.h
>>>>> @@ -143,7 +143,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align)
>>>>>  {
>>>>>  	return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
>>>>>  		 + align - 1) & ~(align - 1))
>>>>> -		+ sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
>>>>> +		+ sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num;
>>>>>  }
>>>>>  
>>>>>  /* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */
>>>>
>>>> Hi:
>>>> I'm not deep into it, but I think you can see this:
>>>> http://marc.info/?l=git-commits-head&m=130687915816130&w=2
>>>>
>>>> Thanks
>>>> -Wanlong Gao
>>>>
>>>
>>> Thanks.
>>>
>>> I checked the comments, and think we should patch vring_init
>>> and vring_size according to the layout description in the comments.
>>> Right?
>>
>> New patch generated. Please check it. Thanks,
> 
> 
>> [PATCH] virtio: modify vring_init and vring_size to take account of the layout containing *_event_idx
>>
>> The patch is against 3.1-rc3.
>>
>> Based on the layout description in the comments, take account of
>> the *_event_idx in functions vring_init and vring_size.
>>
>> Signed-off-by: Wang Sheng-Hui <shhuiw@...il.com>
> 
> Is this a bugfix or just a cleanup?
> Alignment makes us get the same values with and without, right?

It's just a cleanup.
For normal case, the value 16 is too small compared with
the alignment, I think.

> 
>> ---
>>  include/linux/virtio_ring.h |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
>> index 4a32cb6..300af76 100644
>> --- a/include/linux/virtio_ring.h
>> +++ b/include/linux/virtio_ring.h
>> @@ -135,13 +135,13 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
>>  	vr->num = num;
>>  	vr->desc = p;
>>  	vr->avail = p + num*sizeof(struct vring_desc);
>> -	vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1)
>> -			    & ~(align - 1));
>> +	vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + 16
>> +		+ align-1) & ~(align - 1));
>>  }
>>  
>>  static inline unsigned vring_size(unsigned int num, unsigned long align)
>>  {
>> -	return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
>> +	return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
>>  		 + align - 1) & ~(align - 1))
>>  		+ sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
>>  }
>> -- 
>> 1.7.1
>>

--
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