Skip to content

Commit dbdcc90

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm ioctl: log an error if the ioctl structure is corrupted
This will help triage bugs when userspace is passing invalid ioctl structure to the kernel. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> [snitzer: log errors using DMERR instead of DMWARN] Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 3f72821 commit dbdcc90

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/md/dm-ioctl.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,21 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
891891
struct hash_cell *hc = NULL;
892892

893893
if (*param->uuid) {
894-
if (*param->name || param->dev)
894+
if (*param->name || param->dev) {
895+
DMERR("Invalid ioctl structure: uuid %s, name %s, dev %llx",
896+
param->uuid, param->name, (unsigned long long)param->dev);
895897
return NULL;
898+
}
896899

897900
hc = __get_uuid_cell(param->uuid);
898901
if (!hc)
899902
return NULL;
900903
} else if (*param->name) {
901-
if (param->dev)
904+
if (param->dev) {
905+
DMERR("Invalid ioctl structure: name %s, dev %llx",
906+
param->name, (unsigned long long)param->dev);
902907
return NULL;
908+
}
903909

904910
hc = __get_name_cell(param->name);
905911
if (!hc)
@@ -1851,8 +1857,11 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
18511857
if (copy_from_user(param_kernel, user, minimum_data_size))
18521858
return -EFAULT;
18531859

1854-
if (param_kernel->data_size < minimum_data_size)
1860+
if (param_kernel->data_size < minimum_data_size) {
1861+
DMERR("Invalid data size in the ioctl structure: %u",
1862+
param_kernel->data_size);
18551863
return -EINVAL;
1864+
}
18561865

18571866
secure_data = param_kernel->flags & DM_SECURE_DATA_FLAG;
18581867

0 commit comments

Comments
 (0)