Re: [PATCH] kernel/taskstats: fix wrong nla type for {cgroup,task}stats policy

From: Johannes Berg
Date: Thu Mar 26 2020 - 17:13:25 EST


On Thu, 2020-03-26 at 15:11 -0600, David Ahern wrote:
>
> > na->nla_len = nla_len + 1 + NLA_HDRLEN;
> >
> > // but this??? the nla_len of a netlink attribute should just be
> > // the len ... what's NLA_HDRLEN doing here? this isn't nested
> > // here we end up just reserving 1+NLA_HDRLEN too much space

[...]

> I do not get the error message with this change as Johannes points out
> above:
>
> diff --git a/tools/accounting/getdelays.c b/tools/accounting/getdelays.c
> index 8cb504d30384..e90fd133df0e 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;

Oops, thanks for the correction - indeed NLA_HDRLEN is included, I was
wrong above.

johannes