[PATCH] vsock: ratelimit unknown ioctl error message

Subsystems: networking [general], the rest, vm sockets (af_vsock) · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, Stefano Garzarella

STALE2191d

12 messages, 4 authors, 2020-10-26 · open the first message on its own page

[PATCH] vsock: ratelimit unknown ioctl error message

From: Colin King <hidden>
Date: 2020-10-23 12:21:22

From: Colin Ian King <redacted>

When exercising the kernel with stress-ng with some ioctl tests the
"Unknown ioctl" error message is spamming the kernel log at a high
rate. Rate limit this message to reduce the noise.

Signed-off-by: Colin Ian King <redacted>
---
 net/vmw_vsock/af_vsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 9e93bc201cc0..b8feb9223454 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2072,7 +2072,7 @@ static long vsock_dev_do_ioctl(struct file *filp,
 		break;
 
 	default:
-		pr_err("Unknown ioctl %d\n", cmd);
+		pr_err_ratelimited("Unknown ioctl %d\n", cmd);
 		retval = -EINVAL;
 	}
 
-- 
2.27.0

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2020-10-23 14:10:02

On Fri, Oct 23, 2020 at 01:21:13PM +0100, Colin King wrote:
quoted hunk
From: Colin Ian King <redacted>

When exercising the kernel with stress-ng with some ioctl tests the
"Unknown ioctl" error message is spamming the kernel log at a high
rate. Rate limit this message to reduce the noise.

Signed-off-by: Colin Ian King <redacted>
---
net/vmw_vsock/af_vsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 9e93bc201cc0..b8feb9223454 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2072,7 +2072,7 @@ static long vsock_dev_do_ioctl(struct file *filp,
		break;

	default:
-		pr_err("Unknown ioctl %d\n", cmd);
+		pr_err_ratelimited("Unknown ioctl %d\n", cmd);
Make sense, or maybe can we remove the error message returning only the
-EINVAL?

Both cases are fine for me:
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
		retval = -EINVAL;
	}

-- 
2.27.0

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Jakub Kicinski <kuba@kernel.org>
Date: 2020-10-23 20:25:45

On Fri, 23 Oct 2020 16:09:47 +0200 Stefano Garzarella wrote:
On Fri, Oct 23, 2020 at 01:21:13PM +0100, Colin King wrote:
quoted
From: Colin Ian King <redacted>

When exercising the kernel with stress-ng with some ioctl tests the
"Unknown ioctl" error message is spamming the kernel log at a high
rate. Rate limit this message to reduce the noise.

Signed-off-by: Colin Ian King <redacted>
---
net/vmw_vsock/af_vsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 9e93bc201cc0..b8feb9223454 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2072,7 +2072,7 @@ static long vsock_dev_do_ioctl(struct file *filp,
		break;

	default:
-		pr_err("Unknown ioctl %d\n", cmd);
+		pr_err_ratelimited("Unknown ioctl %d\n", cmd);  
Make sense, or maybe can we remove the error message returning only the
-EINVAL?
+1
Both cases are fine for me:
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

RE: [PATCH] vsock: ratelimit unknown ioctl error message

From: David Laight <hidden>
Date: 2020-10-23 21:31:05

From: Stefano Garzarella
Sent: 23 October 2020 15:10

On Fri, Oct 23, 2020 at 01:21:13PM +0100, Colin King wrote:
quoted
From: Colin Ian King <redacted>

When exercising the kernel with stress-ng with some ioctl tests the
"Unknown ioctl" error message is spamming the kernel log at a high
rate. Rate limit this message to reduce the noise.

Signed-off-by: Colin Ian King <redacted>
---
net/vmw_vsock/af_vsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 9e93bc201cc0..b8feb9223454 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2072,7 +2072,7 @@ static long vsock_dev_do_ioctl(struct file *filp,
		break;

	default:
-		pr_err("Unknown ioctl %d\n", cmd);
+		pr_err_ratelimited("Unknown ioctl %d\n", cmd);
Make sense, or maybe can we remove the error message returning only the
-EINVAL?
Isn't the canonical error for unknown ioctl codes -ENOTTY?

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2020-10-26 08:43:10

On Fri, Oct 23, 2020 at 09:30:59PM +0000, David Laight wrote:
From: Stefano Garzarella
quoted
Sent: 23 October 2020 15:10

On Fri, Oct 23, 2020 at 01:21:13PM +0100, Colin King wrote:
quoted
From: Colin Ian King <redacted>

When exercising the kernel with stress-ng with some ioctl tests the
"Unknown ioctl" error message is spamming the kernel log at a high
rate. Rate limit this message to reduce the noise.

Signed-off-by: Colin Ian King <redacted>
---
net/vmw_vsock/af_vsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 9e93bc201cc0..b8feb9223454 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2072,7 +2072,7 @@ static long vsock_dev_do_ioctl(struct file *filp,
		break;

	default:
-		pr_err("Unknown ioctl %d\n", cmd);
+		pr_err_ratelimited("Unknown ioctl %d\n", cmd);
Make sense, or maybe can we remove the error message returning only the
-EINVAL?
Isn't the canonical error for unknown ioctl codes -ENOTTY?
Oh, thanks for pointing that out!

I had not paid attention to the error returned, but looking at it I noticed that perhaps the most appropriate would be -ENOIOCTLCMD.
In the ioctl syscall we return -ENOTTY, if the callback returns -ENOIOCTLCMD.

What do you think?

Stefano

RE: [PATCH] vsock: ratelimit unknown ioctl error message

From: David Laight <hidden>
Date: 2020-10-26 09:13:31

From: Stefano Garzarella
Sent: 26 October 2020 08:43
...
quoted
Isn't the canonical error for unknown ioctl codes -ENOTTY?
Oh, thanks for pointing that out!

I had not paid attention to the error returned, but looking at it I
noticed that perhaps the most appropriate would be -ENOIOCTLCMD.
In the ioctl syscall we return -ENOTTY, if the callback returns
-ENOIOCTLCMD.

What do you think?
It is 729 v 443 in favour of ENOTTY (based on grep).

No idea where ENOIOCTLCMD comes from, but ENOTTY probably
goes back to the early 1970s.

The fact that the ioctl wrapper converts the value is a good
hint that userspace expects ENOTTY.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2020-10-26 09:39:42

On Mon, Oct 26, 2020 at 09:13:23AM +0000, David Laight wrote:
From: Stefano Garzarella
quoted
Sent: 26 October 2020 08:43
...
quoted
quoted
Isn't the canonical error for unknown ioctl codes -ENOTTY?
Oh, thanks for pointing that out!

I had not paid attention to the error returned, but looking at it I
noticed that perhaps the most appropriate would be -ENOIOCTLCMD.
In the ioctl syscall we return -ENOTTY, if the callback returns
-ENOIOCTLCMD.

What do you think?
It is 729 v 443 in favour of ENOTTY (based on grep).
Under net/ it is 6 vs 83 in favour of ENOIOCTLCMD.
No idea where ENOIOCTLCMD comes from, but ENOTTY probably
goes back to the early 1970s.
Me too.
The fact that the ioctl wrapper converts the value is a good
hint that userspace expects ENOTTY.
Agree on that, but since we are not interfacing directly with userspace, I think it is better to return the more specific error (ENOIOCTLCMD).

Thanks,
Stefano

RE: [PATCH] vsock: ratelimit unknown ioctl error message

From: David Laight <hidden>
Date: 2020-10-26 09:46:24

From: Stefano Garzarella
Sent: 26 October 2020 09:39

On Mon, Oct 26, 2020 at 09:13:23AM +0000, David Laight wrote:
quoted
From: Stefano Garzarella
quoted
Sent: 26 October 2020 08:43
...
quoted
quoted
Isn't the canonical error for unknown ioctl codes -ENOTTY?
Oh, thanks for pointing that out!

I had not paid attention to the error returned, but looking at it I
noticed that perhaps the most appropriate would be -ENOIOCTLCMD.
In the ioctl syscall we return -ENOTTY, if the callback returns
-ENOIOCTLCMD.

What do you think?
It is 729 v 443 in favour of ENOTTY (based on grep).
Under net/ it is 6 vs 83 in favour of ENOIOCTLCMD.
quoted
No idea where ENOIOCTLCMD comes from, but ENOTTY probably
goes back to the early 1970s.
Me too.
quoted
The fact that the ioctl wrapper converts the value is a good
hint that userspace expects ENOTTY.
Agree on that, but since we are not interfacing directly with userspace,
I think it is better to return the more specific error (ENOIOCTLCMD).
I bet Linux thought it could use a different error code then
found that 'unknown ioctl' was spelt ENOTTY.

Back in the old days error values were probably almost unique.
strerror(EAGIAN) was "No more processes" for a long time!

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2020-10-26 10:02:16

On Mon, Oct 26, 2020 at 09:46:17AM +0000, David Laight wrote:
From: Stefano Garzarella
quoted
Sent: 26 October 2020 09:39

On Mon, Oct 26, 2020 at 09:13:23AM +0000, David Laight wrote:
quoted
From: Stefano Garzarella
quoted
Sent: 26 October 2020 08:43
...
quoted
quoted
Isn't the canonical error for unknown ioctl codes -ENOTTY?
Oh, thanks for pointing that out!

I had not paid attention to the error returned, but looking at it I
noticed that perhaps the most appropriate would be -ENOIOCTLCMD.
In the ioctl syscall we return -ENOTTY, if the callback returns
-ENOIOCTLCMD.

What do you think?
It is 729 v 443 in favour of ENOTTY (based on grep).
Under net/ it is 6 vs 83 in favour of ENOIOCTLCMD.
quoted
No idea where ENOIOCTLCMD comes from, but ENOTTY probably
goes back to the early 1970s.
Me too.
quoted
The fact that the ioctl wrapper converts the value is a good
hint that userspace expects ENOTTY.
Agree on that, but since we are not interfacing directly with userspace,
I think it is better to return the more specific error (ENOIOCTLCMD).
I bet Linux thought it could use a different error code then
found that 'unknown ioctl' was spelt ENOTTY.
It could be :-)

Anyway, as you pointed out, I think we should change the -EINVAL with -ENOTTY or -ENOIOCTLCMD.

@Jakub what do you suggest?

Thanks,
Stefano

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Jakub Kicinski <kuba@kernel.org>
Date: 2020-10-26 17:56:00

On Mon, 26 Oct 2020 11:01:12 +0100 Stefano Garzarella wrote:
On Mon, Oct 26, 2020 at 09:46:17AM +0000, David Laight wrote:
quoted
From: Stefano Garzarella  
quoted
Sent: 26 October 2020 09:39

On Mon, Oct 26, 2020 at 09:13:23AM +0000, David Laight wrote:  
quoted
From: Stefano Garzarella  
quoted
Sent: 26 October 2020 08:43  
...  
quoted
quoted
Isn't the canonical error for unknown ioctl codes -ENOTTY?
 
Oh, thanks for pointing that out!

I had not paid attention to the error returned, but looking at it I
noticed that perhaps the most appropriate would be -ENOIOCTLCMD.
In the ioctl syscall we return -ENOTTY, if the callback returns
-ENOIOCTLCMD.

What do you think?  
It is 729 v 443 in favour of ENOTTY (based on grep).  
Under net/ it is 6 vs 83 in favour of ENOIOCTLCMD.
 
quoted
No idea where ENOIOCTLCMD comes from, but ENOTTY probably
goes back to the early 1970s.  
Me too.
 
quoted
The fact that the ioctl wrapper converts the value is a good
hint that userspace expects ENOTTY.  
Agree on that, but since we are not interfacing directly with userspace,
I think it is better to return the more specific error (ENOIOCTLCMD).  
I bet Linux thought it could use a different error code then
found that 'unknown ioctl' was spelt ENOTTY.  

6 more quoted lines

ENOIOCTLCMD is a kernel-internal high return code (515) which should 
be returned by the driver, but it's then caught inside the core and
translated to ENOTTY which is then returned to user space.

So you're both right, I guess? But the driver should use ENOIOCTLCMD.

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2020-10-26 18:25:07

On Mon, Oct 26, 2020 at 10:55:48AM -0700, Jakub Kicinski wrote:
On Mon, 26 Oct 2020 11:01:12 +0100 Stefano Garzarella wrote:
quoted
On Mon, Oct 26, 2020 at 09:46:17AM +0000, David Laight wrote:
quoted
From: Stefano Garzarella
quoted
Sent: 26 October 2020 09:39

On Mon, Oct 26, 2020 at 09:13:23AM +0000, David Laight wrote:
quoted
From: Stefano Garzarella
quoted
Sent: 26 October 2020 08:43
...
quoted
quoted
Isn't the canonical error for unknown ioctl codes -ENOTTY?
Oh, thanks for pointing that out!

I had not paid attention to the error returned, but looking at it I
noticed that perhaps the most appropriate would be -ENOIOCTLCMD.
In the ioctl syscall we return -ENOTTY, if the callback returns
-ENOIOCTLCMD.

What do you think?
It is 729 v 443 in favour of ENOTTY (based on grep).
Under net/ it is 6 vs 83 in favour of ENOIOCTLCMD.
quoted
No idea where ENOIOCTLCMD comes from, but ENOTTY probably
goes back to the early 1970s.
Me too.
quoted
The fact that the ioctl wrapper converts the value is a good
hint that userspace expects ENOTTY.
Agree on that, but since we are not interfacing directly with userspace,
I think it is better to return the more specific error (ENOIOCTLCMD).
I bet Linux thought it could use a different error code then
found that 'unknown ioctl' was spelt ENOTTY.

14 more quoted lines

Thanks for clarify!

@Colin, can you send a v2 removing the error message and updating the return value?

Thanks,
Stefano

Re: [PATCH] vsock: ratelimit unknown ioctl error message

From: Jakub Kicinski <kuba@kernel.org>
Date: 2020-10-26 18:37:09

On Mon, 26 Oct 2020 19:24:57 +0100 Stefano Garzarella wrote:
@Colin, can you send a v2 removing the error message and updating the 
return value?
Not as a single patch, please, these are two different changes.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help