[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 11 Nov 2015 08:35:48 +0100
From: Jan Kara <jack@...e.cz>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: Petr Vandrovec <petr@...drovec.name>,
David Howells <dhowells@...hat.com>, Jan Kara <jack@...e.cz>,
Al Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [patch v2] ncpfs: don't allow negative timeouts
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 <dan.carpenter@...cle.com>
Looks good. You can add:
Reviewed-by: Jan Kara <jack@...e.com>
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 <jack@...e.com>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists