From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751208AbcFNKpz (ORCPT ); Tue, 14 Jun 2016 06:45:55 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:17554 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbcFNKpx (ORCPT ); Tue, 14 Jun 2016 06:45:53 -0400 Date: Tue, 14 Jun 2016 13:44:29 +0300 From: Dan Carpenter To: Andy Lutomirski Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , X86 ML , Andy Lutomirski , Dave Hansen , Jan Beulich , "linux-kernel@vger.kernel.org" , kernel-janitors@vger.kernel.org Subject: Re: [patch] x86/ldt: silence a static checker warning Message-ID: <20160614104429.GA32301@mwanda> References: <20160613065755.GC5993@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 13, 2016 at 02:14:39PM -0700, Andy Lutomirski wrote: > On Sun, Jun 12, 2016 at 11:57 PM, Dan Carpenter > wrote: > > It likely doesn't make a difference but my static checker complains > > that we put an upper bound on "size" but not a lower bound. Let's just > > make it unsigned. > > Shouldn't oldsize and newsize in write_ldt as well as the "size" > member in ldt_struct change, too? > Part of the joy of this check is that it complains about every time we cap the upper bound and not the lower bound so it's very thourough, but it also requires very minimal changes to silence the false positives. We know newsize can't be negative. If we change this one variable then we know oldsize and ldt_struct size can't be negative either. The problem really is that I haven't figured out out to deal with recursion... new_ldt = alloc_ldt_struct(old_mm->context.ldt->size); On the first run through, we don't know the value of ->size here so we have to assume it can be anything. regards, dan carpenter