]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dm ioctl: rate limit a couple of ioctl based error messages
authorColin Ian King <colin.i.king@gmail.com>
Thu, 24 Oct 2024 11:04:31 +0000 (12:04 +0100)
committerMikulas Patocka <mpatocka@redhat.com>
Wed, 20 Nov 2024 10:38:04 +0000 (11:38 +0100)
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.

These errors were hit when running the stress-ng's device test.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Acked-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-ioctl.c

index f299ff393a6a2ceda77bcc566f4d121123d9508c..d42eac944eb54bc8596c930000012fd2a068da57 100644 (file)
@@ -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;
        }