[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: Fix xenctl_cpumap_to_cpumask buffer size check


  • To: Jan Beulich <JBeulich@xxxxxxxx>, Matthew Daley <mattjd@xxxxxxxxx>
  • From: Keir Fraser <keir@xxxxxxx>
  • Date: Tue, 13 Nov 2012 10:10:31 +0000
  • Cc: xen-devel@xxxxxxxxxxxxx
  • Delivery-date: Tue, 13 Nov 2012 10:10:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>
  • Thread-index: Ac3Bhxy1iQeGYjnp+EG6ChoSWN+GzA==
  • Thread-topic: [Xen-devel] [PATCH] xen: Fix xenctl_cpumap_to_cpumask buffer size check

On 13/11/2012 08:36, "Jan Beulich" <JBeulich@xxxxxxxx> wrote:

>> Fix by using the correct cpumask buffer size in place of sizeof.
>> 
>> Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx>
> 
> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> However, I would have preferred the adjustment to be ...
> 
>> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
>> index e153cb4..204e951 100644
>> --- a/xen/common/domctl.c
>> +++ b/xen/common/domctl.c
>> @@ -78,7 +78,7 @@ int xenctl_cpumap_to_cpumask(
>>      {
>>          if ( copy_from_guest(bytemap, xenctl_cpumap->bitmap, copy_bytes) )
>>              err = -EFAULT;
>> -        if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes <=
>> sizeof(bytemap)) )
>> +        if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes <= (nr_cpu_ids +
>> 7) / 8) )
> 
>         if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes <= copy_bytes) )
> 
> or even (considering that guest_bytes >= copy_bytes due to the
> way copy_bytes gets initialized)
> 
>         if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes == copy_bytes) )
> 
> to make explicit when exactly the masking is necessary.

Any of the three alternatives is fine by me.

Acked-by: Keir Fraser <keir@xxxxxxx>



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.