mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] getdelays: Fix netlink attribute length
@ 2020-03-27 17:31 David Ahern
  2020-03-28 20:03 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2020-03-27 17:31 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, David Ahern, Yafang Shao, Johannes Berg, Shailabh Nagar

A recent change to the netlink code:
  6e237d099fac ("netlink: Relax attr validation for fixed length types")
logs a warning when programs send messages with invalid attributes
(e.g., wrong length for a u32). Yafang reported this error message
for tools/accounting/getdelays.c.

send_cmd() is wrongly adding 1 to the attribute length. As noted in
include/uapi/linux/netlink.h nla_len should be NLA_HDRLEN + payload
length, so drop the +1.

Fixes: 9e06d3f9f6b1 ("per task delay accounting taskstats interface: documentation fix")
Signed-off-by: David Ahern <dsahern@kernel.org>
Tested-by: Yafang Shao <laoar.shao@gmail.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
---
 tools/accounting/getdelays.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/accounting/getdelays.c b/tools/accounting/getdelays.c
index 8cb504d30384..5ef1c15e88ad 100644
--- a/tools/accounting/getdelays.c
+++ b/tools/accounting/getdelays.c
@@ -136,7 +136,7 @@ static int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid,
 	msg.g.version = 0x1;
 	na = (struct nlattr *) GENLMSG_DATA(&msg);
 	na->nla_type = nla_type;
-	na->nla_len = nla_len + 1 + NLA_HDRLEN;
+	na->nla_len = nla_len + NLA_HDRLEN;
 	memcpy(NLA_DATA(na), nla_data, nla_len);
 	msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-29 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 17:31 [PATCH] getdelays: Fix netlink attribute length David Ahern
2020-03-28 20:03 ` Andrew Morton
2020-03-29 15:44   ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome