From: Jan Kara <jack@suse.cz>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Petr Vandrovec <petr@vandrovec.name>,
David Howells <dhowells@redhat.com>, Jan Kara <jack@suse.cz>,
Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch v2] ncpfs: don't allow negative timeouts
Date: Wed, 11 Nov 2015 08:35:48 +0100 [thread overview]
Message-ID: <20151111073548.GA19064@quack.suse.cz> (raw)
In-Reply-To: <20151110221441.GA30281@mwanda>
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@oracle.com>
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.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@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2015-11-11 7:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 9:09 [patch] ncpfs: don't allow negative timeouts Dan Carpenter
2015-11-10 9:19 ` Jan Kara
2015-11-10 22:14 ` [patch v2] " Dan Carpenter
2015-11-11 7:35 ` Jan Kara [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151111073548.GA19064@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=dan.carpenter@oracle.com \
--cc=dhowells@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=petr@vandrovec.name \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox