Skip to contentSkip to conversation

getdelays: Fix netlink attribute length

PATCH Applied David Ahern 3 participants 3 messages Mar 27, 2020 – Mar 29, 2020 Task delay monitoring tools

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 getdelays: Fix netlink attribute length

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")
Cc Johannes Berg <[email protected]>
Cc Shailabh Nagar <[email protected]>
---
 tools/accounting/getdelays.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/accounting/getdelays.c +1 -1
index 8cb504d30384..5ef1c15e88ad 100644
@@ -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);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 9 lines · On Fri, 27 Mar 2020 11:31:11 -0600 David Ahern <[email protected]> wrote:

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.

Thanks.

Quoted 3 lines
Fixes 9e06d3f9f6b1 ("per task delay accounting taskstats interface: documentation fix")

I'll add Reported-by: as well.

Quoted 2 lines
Cc Johannes Berg <[email protected]>
Cc Shailabh Nagar <[email protected]>

Is this worth a cc:stable?