From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbbKKHfz (ORCPT ); Wed, 11 Nov 2015 02:35:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:57140 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752234AbbKKHfw (ORCPT ); Wed, 11 Nov 2015 02:35:52 -0500 Date: Wed, 11 Nov 2015 08:35:48 +0100 From: Jan Kara To: Dan Carpenter Cc: Petr Vandrovec , David Howells , Jan Kara , Al Viro , Andrew Morton , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [patch v2] ncpfs: don't allow negative timeouts Message-ID: <20151111073548.GA19064@quack.suse.cz> References: <20151110091923.GE26699@quack.suse.cz> <20151110221441.GA30281@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151110221441.GA30281@mwanda> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 11-11-15 01:14:41, Dan Carpenter wrote: > This code causes a static checker warning because it's a user controlled > variable where we cap the upper bound but not the lower bound. Let's > return an -EINVAL for negative timeouts. > > Signed-off-by: Dan Carpenter Looks good. You can add: Reviewed-by: Jan Kara Honza > --- > v2: in the original I just ignored the invalid data and went with the > default but now it returns -EINVAL. > > diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c > index 79b1130..ebf45d2 100644 > --- a/fs/ncpfs/ioctl.c > +++ b/fs/ncpfs/ioctl.c > @@ -525,7 +525,9 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg > switch (rqdata.cmd) { > case NCP_LOCK_EX: > case NCP_LOCK_SH: > - if (rqdata.timeout == 0) > + if (rqdata.timeout < 0) > + return -EINVAL; > + else if (rqdata.timeout == 0) > rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT; > else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT) > rqdata.timeout = NCP_LOCK_MAX_TIMEOUT; -- Jan Kara SUSE Labs, CR