Skip to content

Commit

Permalink
netlink: revert broken, broken "2-clause nla_ok()"
Browse files Browse the repository at this point in the history
Commit 4f7df33
"netlink: 2-clause nla_ok()" is BROKEN.

First clause tests if "->nla_len" could even be accessed at all,
it can not possibly be omitted.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alexey Dobriyan authored and David S. Miller committed Dec 13, 2016
1 parent a220871 commit 3e1ed98
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/net/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ static inline int nla_len(const struct nlattr *nla)
*/
static inline int nla_ok(const struct nlattr *nla, int remaining)
{
return nla->nla_len >= sizeof(*nla) &&
return remaining >= (int) sizeof(*nla) &&
nla->nla_len >= sizeof(*nla) &&
nla->nla_len <= remaining;
}

Expand Down

0 comments on commit 3e1ed98

Please sign in to comment.