From: Alexey Dobriyan Date: Tue, 13 Dec 2016 19:30:15 +0000 (+0300) Subject: netlink: revert broken, broken "2-clause nla_ok()" X-Git-Tag: v5.15~12212^2~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e1ed981b7a903ba81199d4d25b80c6bba705160;p=platform%2Fkernel%2Flinux-starfive.git netlink: revert broken, broken "2-clause nla_ok()" Commit 4f7df337fe79bba1e4c2d525525d63b5ba186bbd "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 Signed-off-by: David S. Miller --- diff --git a/include/net/netlink.h b/include/net/netlink.h index dd657a3..d3938f1 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -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; }