Commit 6bb43b5d authored by Milan Broz's avatar Milan Broz Committed by Alasdair G Kergon
Browse files

dm ioctl: prepare for crypt key wiping



Prepare code for implementing buffer wipe flag.
No functional change in this patch.

Signed-off-by: default avatarMilan Broz <mbroz@redhat.com>
Acked-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent de8be5ac
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -1501,11 +1501,6 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user)
	return r;
}

static void free_params(struct dm_ioctl *param)
{
	vfree(param);
}

static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
{
	struct dm_ioctl tmp, *dmi;
@@ -1520,13 +1515,15 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
	if (!dmi)
		return -ENOMEM;

	if (copy_from_user(dmi, user, tmp.data_size)) {
		vfree(dmi);
		return -EFAULT;
	}
	if (copy_from_user(dmi, user, tmp.data_size))
		goto bad;

	*param = dmi;
	return 0;

bad:
	vfree(dmi);
	return -EFAULT;
}

static int validate_params(uint cmd, struct dm_ioctl *param)
@@ -1564,7 +1561,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
	unsigned int cmd;
	struct dm_ioctl *uninitialized_var(param);
	ioctl_fn fn = NULL;
	size_t param_size;
	size_t input_param_size;

	/* only root can play with this */
	if (!capable(CAP_SYS_ADMIN))
@@ -1605,6 +1602,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
	 * Copy the parameters into kernel space.
	 */
	r = copy_params(user, &param);
	input_param_size = param->data_size;

	current->flags &= ~PF_MEMALLOC;

@@ -1615,9 +1613,8 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
	if (r)
		goto out;

	param_size = param->data_size;
	param->data_size = sizeof(*param);
	r = fn(param, param_size);
	r = fn(param, input_param_size);

	/*
	 * Copy the results back to userland.
@@ -1626,7 +1623,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
		r = -EFAULT;

out:
	free_params(param);
	vfree(param);
	return r;
}