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: Thomas Graf <tgraf@suug.ch>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Thomas Graf and committed by David S. Miller b9a2f2e4 071f92d0

+6 -5
+6 -5
include/net/netlink.h
··· 772 772 const struct nla_policy *policy, 773 773 int len) 774 774 { 775 - if (nla_len(nla) < len) 775 + int nested_len = nla_len(nla) - NLA_ALIGN(len); 776 + 777 + if (nested_len < 0) 776 778 return -1; 777 - if (nla_len(nla) >= NLA_ALIGN(len) + sizeof(struct nlattr)) 778 - return nla_parse_nested(tb, maxtype, 779 - nla_data(nla) + NLA_ALIGN(len), 780 - policy); 779 + if (nested_len >= nla_attr_size(0)) 780 + return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len), 781 + nested_len, policy); 781 782 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); 782 783 return 0; 783 784 }