Received: from eggs.gnu.org ([2001:4830:134:3::10]:52022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsyie-00019U-UT for qemu-devel@nongnu.org; Fri, 06 Jun 2014 14:18:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsyiY-00062j-On for qemu-devel@nongnu.org; Fri, 06 Jun 2014 14:18:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsyiY-00062V-HK for qemu-devel@nongnu.org; Fri, 06 Jun 2014 14:18:18 -0400 Date: Fri, 6 Jun 2014 15:18:12 -0300 From: Eduardo Habkost Message-ID: <20140606181812.GA17594@otherpad.lan.raisama.net> References: <20140605221842.GI15000@otherpad.lan.raisama.net> <87egz2r2pv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87egz2r2pv.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH] vl.c: Check -smp option ranges before setting int globals List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Peter Maydell , Marcelo Tosatti , qemu-devel@nongnu.org, Anthony Liguori , Igor Mammedov , Andreas =?iso-8859-1?Q?F=E4rber?= On Fri, Jun 06, 2014 at 08:06:52AM +0200, Markus Armbruster wrote: > Eduardo Habkost writes: > > > When parsing the -smp option, check if the values (that can be anywhere > > in the [0, UINT64_MAX] range) are in the int range before setting the > > int globals smp_cpus, max_cpus, smp_cores, smp_threads. > > > > Without this, it was posbible to make smp_cpus and max_cpus negative. > > > > Signed-off-by: Eduardo Habkost > > The INT_MAX limit might be too generous, but your code sure beats the > silent truncation we have now. > We will enforce other less generous limits (i.e. machine->max_cpus, MAX_CPUMASK_BITS) later, outside smp_parse(), on the machine initialization code. These new checks are just to make sure smp_parse() won't silently truncate the values when setting the globals (which is impossible to check outside smp_parse()). > Reviewed-by: Markus Armbruster Thanks! -- Eduardo