* [patch] ncpfs: don't allow negative timeouts
@ 2015-11-10 9:09 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2015-11-10 9:09 UTC (permalink / raw)
To: Petr Vandrovec
Cc: Jan Kara, David Howells, Andrew Morton, Al Viro, linux-kernel,
kernel-janitors
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. If
someone passes us a negative timeout then I guess lets set it to the
default.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 79b1130..c07498a 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -525,7 +525,7 @@ 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)
rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT;
else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT)
rqdata.timeout = NCP_LOCK_MAX_TIMEOUT;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [patch] ncpfs: don't allow negative timeouts
@ 2015-11-10 9:09 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2015-11-10 9:09 UTC (permalink / raw)
To: Petr Vandrovec
Cc: Jan Kara, David Howells, Andrew Morton, Al Viro, linux-kernel,
kernel-janitors
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. If
someone passes us a negative timeout then I guess lets set it to the
default.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 79b1130..c07498a 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -525,7 +525,7 @@ 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)
rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT;
else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT)
rqdata.timeout = NCP_LOCK_MAX_TIMEOUT;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch] ncpfs: don't allow negative timeouts
2015-11-10 9:09 ` Dan Carpenter
@ 2015-11-10 9:19 ` Jan Kara
-1 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2015-11-10 9:19 UTC (permalink / raw)
To: Dan Carpenter
Cc: Petr Vandrovec, Jan Kara, David Howells, Andrew Morton, Al Viro,
linux-kernel, kernel-janitors
On Tue 10-11-15 12:09:24, 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. If
> someone passes us a negative timeout then I guess lets set it to the
> default.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
IMHO it would be better to return error from the ioctl. Currently it would
just wrap when converting to u16 anyway...
Honza
>
> diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
> index 79b1130..c07498a 100644
> --- a/fs/ncpfs/ioctl.c
> +++ b/fs/ncpfs/ioctl.c
> @@ -525,7 +525,7 @@ 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)
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] ncpfs: don't allow negative timeouts
@ 2015-11-10 9:19 ` Jan Kara
0 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2015-11-10 9:19 UTC (permalink / raw)
To: Dan Carpenter
Cc: Petr Vandrovec, Jan Kara, David Howells, Andrew Morton, Al Viro,
linux-kernel, kernel-janitors
On Tue 10-11-15 12:09:24, 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. If
> someone passes us a negative timeout then I guess lets set it to the
> default.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
IMHO it would be better to return error from the ioctl. Currently it would
just wrap when converting to u16 anyway...
Honza
>
> diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
> index 79b1130..c07498a 100644
> --- a/fs/ncpfs/ioctl.c
> +++ b/fs/ncpfs/ioctl.c
> @@ -525,7 +525,7 @@ 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)
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch v2] ncpfs: don't allow negative timeouts
2015-11-10 9:19 ` Jan Kara
@ 2015-11-10 22:14 ` Dan Carpenter
-1 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2015-11-10 22:14 UTC (permalink / raw)
To: Petr Vandrovec
Cc: David Howells, Jan Kara, Al Viro, Andrew Morton, linux-kernel,
kernel-janitors
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>
---
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;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [patch v2] ncpfs: don't allow negative timeouts
@ 2015-11-10 22:14 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2015-11-10 22:14 UTC (permalink / raw)
To: Petr Vandrovec
Cc: David Howells, Jan Kara, Al Viro, Andrew Morton, linux-kernel,
kernel-janitors
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>
---
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;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch v2] ncpfs: don't allow negative timeouts
2015-11-10 22:14 ` Dan Carpenter
@ 2015-11-11 7:35 ` Jan Kara
-1 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2015-11-11 7:35 UTC (permalink / raw)
To: Dan Carpenter
Cc: Petr Vandrovec, David Howells, Jan Kara, Al Viro, Andrew Morton,
linux-kernel, kernel-janitors
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch v2] ncpfs: don't allow negative timeouts
@ 2015-11-11 7:35 ` Jan Kara
0 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2015-11-11 7:35 UTC (permalink / raw)
To: Dan Carpenter
Cc: Petr Vandrovec, David Howells, Jan Kara, Al Viro, Andrew Morton,
linux-kernel, kernel-janitors
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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-11-11 7:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10 9:09 [patch] ncpfs: don't allow negative timeouts Dan Carpenter
2015-11-10 9:09 ` Dan Carpenter
2015-11-10 9:19 ` Jan Kara
2015-11-10 9:19 ` Jan Kara
2015-11-10 22:14 ` [patch v2] " Dan Carpenter
2015-11-10 22:14 ` Dan Carpenter
2015-11-11 7:35 ` Jan Kara
2015-11-11 7:35 ` Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.