Skip to contentSkip to conversation

dm ioctl: rate limit a couple of ioctl based error messages

PATCH In review Colin Ian King 3 participants 5 messages Oct 24, 2024 – Oct 31, 2024 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm ioctl: rate limit a couple of ioctl based error messages

It is possible to spam the kernel log with a misbehaving user process that is passing incorrect dm ioctls to /dev/mapper/control. Use a rate limit on these error messages to reduce the noise.

---
 drivers/md/dm-ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-ioctl.c +2 -2
index f299ff393a6a..d42eac944eb5 100644
@@ -1912,7 +1912,7 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user,
 
 	if ((kernel_params->version[0] != DM_VERSION_MAJOR) ||
 	    (kernel_params->version[1] > DM_VERSION_MINOR)) {
-		DMERR("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
+		DMERR_LIMIT("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
 		      DM_VERSION_MAJOR, DM_VERSION_MINOR,
 		      DM_VERSION_PATCHLEVEL,
 		      kernel_params->version[0],
@@ -1961,7 +1961,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
 
 	if (unlikely(param_kernel->data_size < minimum_data_size) ||
 	    unlikely(param_kernel->data_size > DM_MAX_TARGETS * DM_MAX_TARGET_PARAMS)) {
-		DMERR("Invalid data size in the ioctl structure: %u",
+		DMERR_LIMIT("Invalid data size in the ioctl structure: %u",
 		      param_kernel->data_size);
 		return -EINVAL;
 	}
Signature · 1 line
2.39.5
maintainer
#1 lore raw

Hi

I'd like to ask - have you experienced these errors? What was the process that triggered them? Was it some robot that tests syscalls with random parameters?

Mikulas

Quoted 34 lines · Colin Ian King

It is possible to spam the kernel log with a misbehaving user process that is passing incorrect dm ioctls to /dev/mapper/control. Use a rate limit on these error messages to reduce the noise.

---
 drivers/md/dm-ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-ioctl.c +2 -2
index f299ff393a6a..d42eac944eb5 100644
@@ -1912,7 +1912,7 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user,
 
 	if ((kernel_params->version[0] != DM_VERSION_MAJOR) ||
 	    (kernel_params->version[1] > DM_VERSION_MINOR)) {
-		DMERR("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
+		DMERR_LIMIT("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
 		      DM_VERSION_MAJOR, DM_VERSION_MINOR,
 		      DM_VERSION_PATCHLEVEL,
 		      kernel_params->version[0],
@@ -1961,7 +1961,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
 
 	if (unlikely(param_kernel->data_size < minimum_data_size) ||
 	    unlikely(param_kernel->data_size > DM_MAX_TARGETS * DM_MAX_TARGET_PARAMS)) {
-		DMERR("Invalid data size in the ioctl structure: %u",
+		DMERR_LIMIT("Invalid data size in the ioctl structure: %u",
 		      param_kernel->data_size);
 		return -EINVAL;
 	}
Signature · 1 line
2.39.5
#2 lore raw
Quoted 5 lines · Mikulas Patocka

Hi

I'd like to ask - have you experienced these errors? What was the process that triggered them? Was it some robot that tests syscalls with random parameters?

I hit this when running stress-ng's dev test, this exercises various ioctls for race conditions. It's not a major issue, just a corner case found when I was running some stress tests.

Colin

Quoted 41 lines

Mikulas

Quoted 34 lines · Colin Ian King

It is possible to spam the kernel log with a misbehaving user process that is passing incorrect dm ioctls to /dev/mapper/control. Use a rate limit on these error messages to reduce the noise.

---
  drivers/md/dm-ioctl.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-ioctl.c +2 -2
index f299ff393a6a..d42eac944eb5 100644
@@ -1912,7 +1912,7 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user,
 
  	if ((kernel_params->version[0] != DM_VERSION_MAJOR) ||
  	    (kernel_params->version[1] > DM_VERSION_MINOR)) {
-		DMERR("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
+		DMERR_LIMIT("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
  		      DM_VERSION_MAJOR, DM_VERSION_MINOR,
  		      DM_VERSION_PATCHLEVEL,
  		      kernel_params->version[0],
@@ -1961,7 +1961,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
 
  	if (unlikely(param_kernel->data_size < minimum_data_size) ||
  	    unlikely(param_kernel->data_size > DM_MAX_TARGETS * DM_MAX_TARGET_PARAMS)) {
-		DMERR("Invalid data size in the ioctl structure: %u",
+		DMERR_LIMIT("Invalid data size in the ioctl structure: %u",
  		      param_kernel->data_size);
  		return -EINVAL;
  	}
Signature · 1 line
2.39.5
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Colin Ian King
Quoted 5 lines · Colin Ian King

It is possible to spam the kernel log with a misbehaving user process that is passing incorrect dm ioctls to /dev/mapper/control. Use a rate limit on these error messages to reduce the noise.

Mikulas, please update the header to include the context that stress-ng is what Colin was using when he experienced excessive warnings.

Thanks.

maintainer
#4 lore raw
Quoted 7 lines · Mike Snitzer
Quoted 5 lines · Colin Ian King

It is possible to spam the kernel log with a misbehaving user process that is passing incorrect dm ioctls to /dev/mapper/control. Use a rate limit on these error messages to reduce the noise.

Quoted 7 lines

Mikulas, please update the header to include the context that stress-ng is what Colin was using when he experienced excessive warnings.

Thanks.

OK, done.

Mikulas