Skip to content

Commit

Permalink
GFS2: Require user to provide argument for FITRIM
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Lukas Czerner authored and swhiteho committed Nov 7, 2012
1 parent 73738a7 commit 3a238ad
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions fs/gfs2/rgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,11 +1270,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);
Expand Down Expand Up @@ -1323,7 +1319,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;
Expand Down

0 comments on commit 3a238ad

Please sign in to comment.