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: <4E5B36EC.8030303@gmail.com>
Date:	Mon, 29 Aug 2011 14:51:24 +0800
From:	Wang Sheng-Hui <shhuiw@...il.com>
To:	Rusty Russell <rusty@...tcorp.com.au>
CC:	wanlong.gao@...il.com, mst@...hat.com,
	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月29日 10:53, Rusty Russell wrote:
> On Sat, 27 Aug 2011 17:52:02 +0800, Wang Sheng-Hui <shhuiw@...il.com> wrote:
>> On 2011年08月27日 17:34, Wang Sheng-Hui wrote:
>> 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));
>>  }
> 
> This + 16 should be + sizeof(__u16), right?  It's just the
> used_event_idx which has been added:

Yes.

> 
>  *	__u16 available[num];
>  *	__u16 used_event_idx;
>  *
>  *	// Padding to the next align boundary.
>  *	char pad[];
>  *
>  * [USED]
> 
>>  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;
> 
> This is correct.
> 
> And, yes, since align is always 4096, it's currently just a cleanup, but
> it makes things much less confusing!
> 
> Thanks,
> Rusty.

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