From 34d65cd837d0c77fac0c0da632c616030b2927e3 Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Fri, 21 Jun 2019 17:00:44 -0400 Subject: RDMA/netlink: Audit policy settings for netlink attributes For all string attributes for which we don't currently accept the element as input, we only use it as output, set the string length to RDMA_NLDEV_ATTR_EMPTY_STRING which is defined as 1. That way we will only accept a null string for that element. This will prevent someone from writing a new input routine that uses the element without also updating the policy to have a valid value. Also while there, make sure the existing entries that are valid have the correct policy, if not, correct the policy. Remove unnecessary checks for nla_strlcpy() overflow once the policy has been set correctly. Signed-off-by: Doug Ledford Signed-off-by: Jason Gunthorpe --- include/rdma/rdma_netlink.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/rdma/rdma_netlink.h') diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h index c7acbe083428..6631624e4d7c 100644 --- a/include/rdma/rdma_netlink.h +++ b/include/rdma/rdma_netlink.h @@ -6,6 +6,12 @@ #include #include +enum { + RDMA_NLDEV_ATTR_EMPTY_STRING = 1, + RDMA_NLDEV_ATTR_ENTRY_STRLEN = 16, + RDMA_NLDEV_ATTR_CHARDEV_TYPE_SIZE = 32, +}; + struct rdma_nl_cbs { int (*doit)(struct sk_buff *skb, struct nlmsghdr *nlh, struct netlink_ext_ack *extack); -- cgit v1.2.3-59-g8ed1b