xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Keir Fraser <keir@xen.org>
To: Jan Beulich <JBeulich@suse.com>, Matthew Daley <mattjd@gmail.com>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH] xen: Fix xenctl_cpumap_to_cpumask buffer size check
Date: Tue, 13 Nov 2012 10:10:31 +0000	[thread overview]
Message-ID: <CCC7CD17.5206A%keir@xen.org> (raw)
In-Reply-To: <50A214B902000078000A7F88@nat28.tlf.novell.com>

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

>> Fix by using the correct cpumask buffer size in place of sizeof.
>> 
>> Signed-off-by: Matthew Daley <mattjd@gmail.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
> 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@xen.org>

  reply	other threads:[~2012-11-13 10:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13  6:04 [PATCH] xen: Fix xenctl_cpumap_to_cpumask buffer size check Matthew Daley
2012-11-13  8:36 ` Jan Beulich
2012-11-13 10:10   ` Keir Fraser [this message]
2012-11-13 10:17   ` Matthew Daley
2012-11-13 10:58     ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CCC7CD17.5206A%keir@xen.org \
    --to=keir@xen.org \
    --cc=JBeulich@suse.com \
    --cc=mattjd@gmail.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).