Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9a2f2e4 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller
Browse files

netlink: Fix nla_parse_nested_compat() to call nla_parse() directly



The purpose of nla_parse_nested_compat() is to parse attributes which
contain a struct followed by a stream of nested attributes.  So far,
it called nla_parse_nested() to parse the stream of nested attributes
which was wrong, as nla_parse_nested() expects a container attribute
as data which holds the attribute stream.  It needs to call
nla_parse() directly while pointing at the next possible alignment
point after the struct in the beginning of the attribute.

With this patch, I can no longer reproduce the reported leftover
warnings.

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Acked-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 071f92d0
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -772,12 +772,13 @@ static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype,
					    const struct nla_policy *policy,
					    const struct nla_policy *policy,
					    int len)
					    int len)
{
{
	if (nla_len(nla) < len)
	int nested_len = nla_len(nla) - NLA_ALIGN(len);

	if (nested_len < 0)
		return -1;
		return -1;
	if (nla_len(nla) >= NLA_ALIGN(len) + sizeof(struct nlattr))
	if (nested_len >= nla_attr_size(0))
		return nla_parse_nested(tb, maxtype,
		return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len),
					nla_data(nla) + NLA_ALIGN(len),
				 nested_len, policy);
					policy);
	memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
	memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
	return 0;
	return 0;
}
}