Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1563073 > unrolled thread

[PATCH 1/1 linux-next] udf: return inappropriate ioctl instead of argument error

Started byFabian Frederick <fabf@skynet.be>
First post2017-01-19 21:50 +0100
Last post2017-01-20 11:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1 linux-next] udf: return inappropriate ioctl instead of argument error Fabian Frederick <fabf@skynet.be> - 2017-01-19 21:50 +0100
    Re: [PATCH 1/1 linux-next] udf: return inappropriate ioctl instead  of argument error Jan Kara <jack@suse.cz> - 2017-01-20 11:30 +0100

#1563073 — [PATCH 1/1 linux-next] udf: return inappropriate ioctl instead of argument error

FromFabian Frederick <fabf@skynet.be>
Date2017-01-19 21:50 +0100
Subject[PATCH 1/1 linux-next] udf: return inappropriate ioctl instead of argument error
Message-ID<t1rOG-6hY-19@gated-at.bofh.it>
Currently, lsattr for instance in udf directory gives
"udf: Invalid argument While reading flags on ..."

This patch removes argument testing and returns -ENOIOCTLCMD
when command is unknown to have more accurate message like this:
"Inappropriate ioctl for device While reading flags on ..."
If arg is NULL, we return specific operation error anyway.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/udf/file.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/udf/file.c b/fs/udf/file.c
index dbcb3a4a..964620b 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -184,12 +184,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		goto out;
 	}
 
-	if (!arg) {
-		udf_debug("invalid argument to udf_ioctl\n");
-		result = -EINVAL;
-		goto out;
-	}
-
 	switch (cmd) {
 	case UDF_GETVOLIDENT:
 		if (copy_to_user((char __user *)arg,
@@ -220,6 +214,8 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 				      UDF_I(inode)->i_ext.i_data,
 				      UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0;
 		goto out;
+	default:
+		return -ENOIOCTLCMD;
 	}
 
 out:
-- 
2.9.3

[toc] | [next] | [standalone]


#1563458 — Re: [PATCH 1/1 linux-next] udf: return inappropriate ioctl instead of argument error

FromJan Kara <jack@suse.cz>
Date2017-01-20 11:30 +0100
SubjectRe: [PATCH 1/1 linux-next] udf: return inappropriate ioctl instead of argument error
Message-ID<t1ECe-62Y-23@gated-at.bofh.it>
In reply to#1563073
On Thu 19-01-17 21:41:37, Fabian Frederick wrote:
> Currently, lsattr for instance in udf directory gives
> "udf: Invalid argument While reading flags on ..."
> 
> This patch removes argument testing and returns -ENOIOCTLCMD
> when command is unknown to have more accurate message like this:
> "Inappropriate ioctl for device While reading flags on ..."
> If arg is NULL, we return specific operation error anyway.

OK, ENOIOCTLCMD is better than EINVAL but for the case of NULL argument for
correct ioctl command you should keep the check so that we don't fault and
kill the caller instead of returning EINVAL as we used to...

								Honza
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  fs/udf/file.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/udf/file.c b/fs/udf/file.c
> index dbcb3a4a..964620b 100644
> --- a/fs/udf/file.c
> +++ b/fs/udf/file.c
> @@ -184,12 +184,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  		goto out;
>  	}
>  
> -	if (!arg) {
> -		udf_debug("invalid argument to udf_ioctl\n");
> -		result = -EINVAL;
> -		goto out;
> -	}
> -
>  	switch (cmd) {
>  	case UDF_GETVOLIDENT:
>  		if (copy_to_user((char __user *)arg,
> @@ -220,6 +214,8 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  				      UDF_I(inode)->i_ext.i_data,
>  				      UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0;
>  		goto out;
> +	default:
> +		return -ENOIOCTLCMD;
>  	}
>  
>  out:
> -- 
> 2.9.3
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web