[dm-devel] [PATCH] dm-ioctl: log an error if the ioctl structure is corrupted
Mikulas Patocka
mpatocka at redhat.com
Sun Mar 20 21:12:46 UTC 2022
Log an error if the ioctl structure is corrupted. This will help us triage
bugs when when userspace is passing invalid ioctl structure to the kernel.
Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
---
drivers/md/dm-ioctl.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
Index: linux-dm/drivers/md/dm-ioctl.c
===================================================================
--- linux-dm.orig/drivers/md/dm-ioctl.c 2022-03-17 19:19:31.000000000 +0100
+++ linux-dm/drivers/md/dm-ioctl.c 2022-03-20 20:37:34.000000000 +0100
@@ -891,15 +891,21 @@ static struct hash_cell *__find_device_h
struct hash_cell *hc = NULL;
if (*param->uuid) {
- if (*param->name || param->dev)
+ if (*param->name || param->dev) {
+ DMWARN("Invalid ioctl structure: uuid %s, name %s, dev %llx",
+ param->uuid, param->name, (unsigned long long)param->dev);
return NULL;
+ }
hc = __get_uuid_cell(param->uuid);
if (!hc)
return NULL;
} else if (*param->name) {
- if (param->dev)
+ if (param->dev) {
+ DMWARN("Invalid ioctl structure: name %s, dev %llx",
+ param->name, (unsigned long long)param->dev);
return NULL;
+ }
hc = __get_name_cell(param->name);
if (!hc)
@@ -1851,8 +1857,10 @@ static int copy_params(struct dm_ioctl _
if (copy_from_user(param_kernel, user, minimum_data_size))
return -EFAULT;
- if (param_kernel->data_size < minimum_data_size)
+ if (param_kernel->data_size < minimum_data_size) {
+ DMWARN("Invalid data size in the ioctl structure: %u", param_kernel->data_size);
return -EINVAL;
+ }
secure_data = param_kernel->flags & DM_SECURE_DATA_FLAG;
More information about the dm-devel
mailing list