Skip to contentSkip to conversation

netlink: downgrade warning about leftover bytes to debug level

PATCH In review Michal Schmidt 4 participants 9 messages May 27, 2014 – Jun 2, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netlink: downgrade warning about leftover bytes to debug level

Any process is able to send netlink messages with leftover bytes, so downgrade the warning message to pr_debug in order to avoid possible kernel log spam.

---
 lib/nlattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/nlattr.c +2 -2
index fc67547..fbadde6 100644
@@ -201,8 +201,8 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
 	}
 
 	if (unlikely(rem > 0))
-		printk(KERN_WARNING "netlink: %d bytes leftover after parsing "
-		       "attributes.\n", rem);
+		pr_debug("netlink: %d bytes leftover after parsing attributes.\n",
+			 rem);
 
 	err = 0;
 errout:
Signature · 1 line
1.9.3
#1 lore raw
Quoted 3 lines · Michal Schmidt

Any process is able to send netlink messages with leftover bytes, so downgrade the warning message to pr_debug in order to avoid possible kernel log spam.

Yes, but that's not a normal case. I think that the level warning is good, there is something wrong with this kind of messages.

#2 lore raw
Quoted 6 lines · Nicolas Dichtel
Quoted 3 lines · Michal Schmidt

Any process is able to send netlink messages with leftover bytes, so downgrade the warning message to pr_debug in order to avoid possible kernel log spam.

Yes, but that's not a normal case. I think that the level warning is good, there is something wrong with this kind of messages.

As an alternative we could at least guard it with net_ratelimit().

But still, the message indicates a userspace bug. It can be useful for a developer of a netlink library, but not for many more. I think it's odd to let unprivileged userspace spam the dmesg, even if rate-limited. The kernel does not emit warning messages when userspace is buggy in other ways, like calling syscalls with invalid arguments.

Regards,
Michal

#3 lore raw
Quoted 9 lines · Michal Schmidt
Quoted 6 lines · Nicolas Dichtel
Quoted 3 lines · Michal Schmidt

Any process is able to send netlink messages with leftover bytes, so downgrade the warning message to pr_debug in order to avoid possible kernel log spam.

Yes, but that's not a normal case. I think that the level warning is good, there is something wrong with this kind of messages.

As an alternative we could at least guard it with net_ratelimit().

I would prefer this solution.

Quoted 3 lines

But still, the message indicates a userspace bug. It can be useful for a developer of a netlink library, but not for many more.

Or to let you know why a userspace tool does not work ;-)

Quoted 4 lines

I think it's odd to let unprivileged userspace spam the dmesg, even if rate-limited. The kernel does not emit warning messages when userspace is buggy in other ways, like calling syscalls with invalid arguments.

If it's really a problem (this message is here since 2.6.15 and nobody complains), maybe a level between warning and debug may be acceptable.

Regards,
Nicolas

#4 lore raw

PATCH 1/1 netlink: rate-limit leftover bytes warning and print process name

Any process is able to send netlink messages with leftover bytes. Make the warning rate-limited to prevent too much log spam.

The warning is supposed to help find userspace bugs, so print the triggering command name to implicate the buggy program.

---
 lib/nlattr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/nlattr.c +3 -2
index fc67547..31047c4 100644
@@ -201,8 +201,9 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
 	}
 
 	if (unlikely(rem > 0))
-		printk(KERN_WARNING "netlink: %d bytes leftover after parsing "
-		       "attributes.\n", rem);
+		printk_ratelimited(KERN_WARNING
+				   "netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
+				   rem, current->comm);
 
 	err = 0;
 errout:
Signature · 1 line
1.9.3
#5 lore raw

Re: [PATCH] netlink: rate-limit leftover bytes warning and print process name

Hello.

Quoted 16 lines · Michal Schmidt

Any process is able to send netlink messages with leftover bytes. Make the warning rate-limited to prevent too much log spam.

The warning is supposed to help find userspace bugs, so print the triggering command name to implicate the buggy program.

---
  lib/nlattr.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
lib/nlattr.c +0 -0
index fc67547..31047c4 100644

lib/nlattr.c int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head, · line 204

Quoted 6 lines
lib/nlattr.c +1 -2
@@ -201,8 +201,9 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
  	}
 
  	if (unlikely(rem > 0))
-		printk(KERN_WARNING "netlink: %d bytes leftover after parsing "
-		       "attributes.\n", rem);
+		printk_ratelimited(KERN_WARNING

Better pr_warn_ratelimited().

lib/nlattr.c int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head, · line 206

Quoted 2 lines
lib/nlattr.c +2 -0
+				   "netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
+				   rem, current->comm);

WBR, Sergei

maintainer
#8 lore raw

Re: [PATCH] netlink: rate-limit leftover bytes warning and print process name

In reply to Michal Schmidt

From: Michal Schmidt <[email protected]>
Date: Fri, 30 May 2014 14:57:27 +0200

Quoted 7 lines

Any process is able to send netlink messages with leftover bytes. Make the warning rate-limited to prevent too much log spam.

The warning is supposed to help find userspace bugs, so print the triggering command name to implicate the buggy program.

Please use pr_warn_ratelimited() as suggested by Sergei.

Thanks.

#6 lore raw

PATCH v2 1/1 netlink: rate-limit leftover bytes warning and print process name

In reply to Sergei Shtylyov

Any process is able to send netlink messages with leftover bytes. Make the warning rate-limited to prevent too much log spam.

The warning is supposed to help find userspace bugs, so print the triggering command name to implicate the buggy program.

[v2: Use pr_warn_ratelimited instead of printk_ratelimited.]

---
 lib/nlattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/nlattr.c +2 -2
index fc67547..10ad042 100644
@@ -201,8 +201,8 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
 	}
 
 	if (unlikely(rem > 0))
-		printk(KERN_WARNING "netlink: %d bytes leftover after parsing "
-		       "attributes.\n", rem);
+		pr_warn_ratelimited("netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
+				    rem, current->comm);
 
 	err = 0;
 errout:
Signature · 1 line
1.9.3
maintainer Applied
#7 lore raw

Re: [PATCH v2] netlink: rate-limit leftover bytes warning and print process name

From: Michal Schmidt <[email protected]>
Date: Mon, 2 Jun 2014 18:25:02 +0200

Quoted 9 lines

Any process is able to send netlink messages with leftover bytes. Make the warning rate-limited to prevent too much log spam.

The warning is supposed to help find userspace bugs, so print the triggering command name to implicate the buggy program.

[v2: Use pr_warn_ratelimited instead of printk_ratelimited.]

Applied, thanks Michal.