Skip to contentSkip to conversation

gfs2: Require user to provide argument for FITRIM

PATCH New Steven Whitehouse 1 participant 1 message Oct 16, 2012 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 gfs2: Require user to provide argument for FITRIM

In reply to a message not in the archive

Hi,

Thanks for fix up my mistakes :-) Both patches are now in the -nmw tree,

Steve.

Quoted 35 lines · Lukas Czerner

When the fstrim_range argument is not provided by user in FITRIM ioctl we should just return EFAULT and not promoting bad behaviour by filling the structure in kernel. Let the user deal with it.

---
 fs/gfs2/rgrp.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
fs/gfs2/rgrp.c +2 -6
index 3cc402c..ef00006 100644
@@ -1271,11 +1271,7 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
 	if (!blk_queue_discard(q))
 		return -EOPNOTSUPP;
 
-	if (argp == NULL) {
-		r.start = 0;
-		r.len = ULLONG_MAX;
-		r.minlen = 0;
-	} else if (copy_from_user(&r, argp, sizeof(r)))
+	if (copy_from_user(&r, argp, sizeof(r)))
 		return -EFAULT;
 
 	ret = gfs2_rindex_update(sdp);
@@ -1324,7 +1320,7 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
 
 out:
 	r.len = trimmed << 9;
-	if (argp && copy_to_user(argp, &r, sizeof(r)))
+	if (copy_to_user(argp, &r, sizeof(r)))
 		return -EFAULT;
 
 	return ret;