From: Leon Romanovsky Date: Sun, 30 Dec 2018 13:34:09 +0000 (+0200) Subject: rdma: Fix incorrectly handled NLA validation X-Git-Tag: v4.20.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0cabaca38e5fafb455373e2d2747afecc7299fd;p=thirdparty%2Fiproute2.git rdma: Fix incorrectly handled NLA validation mnl_attr_type_valid() receives maximum attribute type, which means that we were supposed to supply the latest valid netlink attribute and not the number of attributes. Such coding mistake caused to failures while NLA attributes were extended. Fixes: 74bd75c2b68d ("rdma: Add basic infrastructure for RDMA tool") Signed-off-by: Leon Romanovsky Signed-off-by: Stephen Hemminger --- diff --git a/rdma/utils.c b/rdma/utils.c index 1a0cf5680..c70233670 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -425,8 +425,8 @@ int rd_attr_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = data; int type; - if (mnl_attr_type_valid(attr, RDMA_NLDEV_ATTR_MAX) < 0) - /* We received uknown attribute */ + if (mnl_attr_type_valid(attr, RDMA_NLDEV_ATTR_MAX - 1) < 0) + /* We received unknown attribute */ return MNL_CB_OK; type = mnl_attr_get_type(attr);