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


Groups > linux.kernel > #1566140 > unrolled thread

[PATCH 1/3 linux-next] udf: fix ioctl errors

Started byFabian Frederick <fabf@skynet.be>
First post2017-01-24 22:00 +0100
Last post2017-01-24 22:00 +0100
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/3 linux-next] udf: fix ioctl errors Fabian Frederick <fabf@skynet.be> - 2017-01-24 22:00 +0100
    [PATCH 3/3 linux-next] udf: remove else after return in udf_ioctl() Fabian Frederick <fabf@skynet.be> - 2017-01-24 22:00 +0100

#1566140 — [PATCH 1/3 linux-next] udf: fix ioctl errors

FromFabian Frederick <fabf@skynet.be>
Date2017-01-24 22:00 +0100
Subject[PATCH 1/3 linux-next] udf: fix ioctl errors
Message-ID<t3gm6-DC-23@gated-at.bofh.it>
Currently, lsattr for instance in udf directory gives
"udf: Invalid argument While reading flags on ..."

This patch returns -ENOIOCTLCMD
when command is unknown to have more accurate message like this:
"Inappropriate ioctl for device While reading flags on ..."

As suggested by Jan Kara, if arg is NULL with a correct ioctl,
we return -VM_FAULT_SIGBUS to report error.

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

diff --git a/fs/udf/file.c b/fs/udf/file.c
index dbcb3a4a..d44b3cb 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -184,9 +184,10 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		goto out;
 	}
 
-	if (!arg) {
+	if (!arg && ((cmd == UDF_GETVOLIDENT) || (cmd == UDF_GETEASIZE) ||
+		     (cmd == UDF_RELOCATE_BLOCKS) || (cmd == UDF_GETEABLOCK))) {
 		udf_debug("invalid argument to udf_ioctl\n");
-		result = -EINVAL;
+		result = -VM_FAULT_SIGBUS;
 		goto out;
 	}
 
@@ -220,6 +221,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]


#1566142 — [PATCH 3/3 linux-next] udf: remove else after return in udf_ioctl()

FromFabian Frederick <fabf@skynet.be>
Date2017-01-24 22:00 +0100
Subject[PATCH 3/3 linux-next] udf: remove else after return in udf_ioctl()
Message-ID<t3gm7-DC-39@gated-at.bofh.it>
In reply to#1566140
else after return is not needed.

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

diff --git a/fs/udf/file.c b/fs/udf/file.c
index 00931fa..a1fec1b 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -194,8 +194,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		if (copy_to_user((char __user *)arg,
 				 UDF_SB(inode->i_sb)->s_volume_ident, 32))
 			return -EFAULT;
-		else
-			return 0;
+		return 0;
 	case UDF_RELOCATE_BLOCKS:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-- 
2.9.3

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web