* [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages
@ 2024-10-24 11:04 Colin Ian King
2024-10-24 14:01 ` Mikulas Patocka
2024-10-29 16:44 ` Mike Snitzer
0 siblings, 2 replies; 5+ messages in thread
From: Colin Ian King @ 2024-10-24 11:04 UTC (permalink / raw)
To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka, dm-devel; +Cc: linux-kernel
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.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/md/dm-ioctl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index f299ff393a6a..d42eac944eb5 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -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;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages
2024-10-24 11:04 [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages Colin Ian King
@ 2024-10-24 14:01 ` Mikulas Patocka
2024-10-24 14:05 ` Colin King (gmail)
2024-10-29 16:44 ` Mike Snitzer
1 sibling, 1 reply; 5+ messages in thread
From: Mikulas Patocka @ 2024-10-24 14:01 UTC (permalink / raw)
To: Colin Ian King; +Cc: Alasdair Kergon, Mike Snitzer, dm-devel, linux-kernel
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
On Thu, 24 Oct 2024, Colin Ian King wrote:
> 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.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/md/dm-ioctl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
> index f299ff393a6a..d42eac944eb5 100644
> --- a/drivers/md/dm-ioctl.c
> +++ b/drivers/md/dm-ioctl.c
> @@ -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;
> }
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages
2024-10-24 14:01 ` Mikulas Patocka
@ 2024-10-24 14:05 ` Colin King (gmail)
0 siblings, 0 replies; 5+ messages in thread
From: Colin King (gmail) @ 2024-10-24 14:05 UTC (permalink / raw)
To: Mikulas Patocka; +Cc: Alasdair Kergon, Mike Snitzer, dm-devel, linux-kernel
On 24/10/2024 15:01, Mikulas Patocka wrote:
> 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
>
> Mikulas
>
>
> On Thu, 24 Oct 2024, Colin Ian King wrote:
>
>> 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.
>>
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>> ---
>> drivers/md/dm-ioctl.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
>> index f299ff393a6a..d42eac944eb5 100644
>> --- a/drivers/md/dm-ioctl.c
>> +++ b/drivers/md/dm-ioctl.c
>> @@ -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;
>> }
>> --
>> 2.39.5
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages
2024-10-24 11:04 [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages Colin Ian King
2024-10-24 14:01 ` Mikulas Patocka
@ 2024-10-29 16:44 ` Mike Snitzer
2024-10-31 15:04 ` Mikulas Patocka
1 sibling, 1 reply; 5+ messages in thread
From: Mike Snitzer @ 2024-10-29 16:44 UTC (permalink / raw)
To: Colin Ian King; +Cc: Alasdair Kergon, Mikulas Patocka, dm-devel, linux-kernel
On Thu, Oct 24, 2024 at 12:04:31PM +0100, Colin Ian King wrote:
> 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.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Mikulas, please update the header to include the context that
stress-ng is what Colin was using when he experienced excessive
warnings.
Thanks.
Acked-by: Mike Snitzer <snitzer@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages
2024-10-29 16:44 ` Mike Snitzer
@ 2024-10-31 15:04 ` Mikulas Patocka
0 siblings, 0 replies; 5+ messages in thread
From: Mikulas Patocka @ 2024-10-31 15:04 UTC (permalink / raw)
To: Mike Snitzer; +Cc: Colin Ian King, Alasdair Kergon, dm-devel, linux-kernel
On Tue, 29 Oct 2024, Mike Snitzer wrote:
> On Thu, Oct 24, 2024 at 12:04:31PM +0100, Colin Ian King wrote:
> > 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.
> >
> > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>
> Mikulas, please update the header to include the context that
> stress-ng is what Colin was using when he experienced excessive
> warnings.
>
> Thanks.
>
> Acked-by: Mike Snitzer <snitzer@kernel.org>
OK, done.
Mikulas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-31 15:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-24 11:04 [PATCH][next] dm ioctl: rate limit a couple of ioctl based error messages Colin Ian King
2024-10-24 14:01 ` Mikulas Patocka
2024-10-24 14:05 ` Colin King (gmail)
2024-10-29 16:44 ` Mike Snitzer
2024-10-31 15:04 ` Mikulas Patocka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox