Skip to content

Commit

Permalink
btrfs: allocate btrfs_ioctl_quota_rescan_args on stack
Browse files Browse the repository at this point in the history
Instead of using kmalloc() to allocate btrfs_ioctl_quota_rescan_args,
allocate btrfs_ioctl_quota_rescan_args on stack, the size is reasonably
small and ioctls are called in process context.

sizeof(btrfs_ioctl_quota_rescan_args) = 64

Reviewed-by: Anand Jain <[email protected]>
Signed-off-by: Goldwyn Rodrigues <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
goldwynr authored and kdave committed Aug 23, 2021
1 parent 98caf95 commit 0afb603
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4403,25 +4403,20 @@ static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg)
static long btrfs_ioctl_quota_rescan_status(struct btrfs_fs_info *fs_info,
void __user *arg)
{
struct btrfs_ioctl_quota_rescan_args *qsa;
struct btrfs_ioctl_quota_rescan_args qsa = {0};
int ret = 0;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

qsa = kzalloc(sizeof(*qsa), GFP_KERNEL);
if (!qsa)
return -ENOMEM;

if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) {
qsa->flags = 1;
qsa->progress = fs_info->qgroup_rescan_progress.objectid;
qsa.flags = 1;
qsa.progress = fs_info->qgroup_rescan_progress.objectid;
}

if (copy_to_user(arg, qsa, sizeof(*qsa)))
if (copy_to_user(arg, &qsa, sizeof(qsa)))
ret = -EFAULT;

kfree(qsa);
return ret;
}

Expand Down

0 comments on commit 0afb603

Please sign in to comment.