Received: from eggs.gnu.org ([2001:4830:134:3::10]:45182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ98u-0006m0-W1 for qemu-devel@nongnu.org; Tue, 24 Feb 2015 01:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQ98r-0003ar-81 for qemu-devel@nongnu.org; Tue, 24 Feb 2015 01:38:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59768) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ98r-0003ai-15 for qemu-devel@nongnu.org; Tue, 24 Feb 2015 01:38:49 -0500 Date: Tue, 24 Feb 2015 07:38:40 +0100 From: Igor Mammedov Message-ID: <20150224073840.24f05832@nial.brq.redhat.com> In-Reply-To: <1423763435-3696-2-git-send-email-ehabkost@redhat.com> References: <1423763435-3696-1-git-send-email-ehabkost@redhat.com> <1423763435-3696-2-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 1/4] numa: Fix off-by-one error at MAX_CPUMASK_BITS check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Paolo Bonzini , Hu Tao , qemu-devel@nongnu.org, "Michael S. Tsirkin" On Thu, 12 Feb 2015 15:50:32 -0200 Eduardo Habkost wrote: > Fix the CPU index check to ensure we don't go beyond the size of the > node_cpu bitmap. > > CPU index is always less than MAX_CPUMASK_BITS, as documented at > sysemu.h: > > > The following shall be true for all CPUs: > > cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS > > Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov > --- > numa.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/numa.c b/numa.c > index 0d15375..41e496b 100644 > --- a/numa.c > +++ b/numa.c > @@ -76,9 +76,9 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp) > } > > for (cpus = node->cpus; cpus; cpus = cpus->next) { > - if (cpus->value > MAX_CPUMASK_BITS) { > + if (cpus->value >= MAX_CPUMASK_BITS) { > error_setg(errp, "CPU number %" PRIu16 " is bigger than %d", > - cpus->value, MAX_CPUMASK_BITS); > + cpus->value, MAX_CPUMASK_BITS - 1); > return; > } > bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);