From: Pavel Rochnyack Date: Mon, 7 May 2018 15:53:23 +0000 (+0700) Subject: netlink plugin: Use of less strict rules in link_filter_cb() X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=48a98886e51c82ee7c0a502a55ca5f8b0ce999bc;p=collectd.git netlink plugin: Use of less strict rules in link_filter_cb() mnl_attr_validate2() function implements strict equality check of kernel and userspace structures size. Additional counters was added to 4.6 Linux kernel, sizes was changed and mismatch can occur. This patch weakened validation. Now Collectd just checks if structures, received from kernel space, has enough data. Closes: #2510 --- diff --git a/src/netlink.c b/src/netlink.c index 1978eb43..d5cbeba0 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -357,10 +357,10 @@ static int link_filter_cb(const struct nlmsghdr *nlh, if (mnl_attr_get_type(attr) != IFLA_STATS64) continue; - if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC, sizeof(*stats.stats64)) < 0) { - ERROR("netlink plugin: link_filter_cb: IFLA_STATS64 mnl_attr_validate2 " - "failed: %s", - STRERRNO); + uint16_t attr_len = mnl_attr_get_payload_len(attr); + if (attr_len < sizeof(*stats.stats64)) { + ERROR("netlink plugin: link_filter_cb: IFLA_STATS64 attribute has " + "insufficient data."); return MNL_CB_ERROR; } stats.stats64 = mnl_attr_get_payload(attr); @@ -374,10 +374,10 @@ static int link_filter_cb(const struct nlmsghdr *nlh, if (mnl_attr_get_type(attr) != IFLA_STATS) continue; - if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC, sizeof(*stats.stats32)) < 0) { - ERROR("netlink plugin: link_filter_cb: IFLA_STATS mnl_attr_validate2 " - "failed: %s", - STRERRNO); + uint16_t attr_len = mnl_attr_get_payload_len(attr); + if (attr_len < sizeof(*stats.stats32)) { + ERROR("netlink plugin: link_filter_cb: IFLA_STATS attribute has " + "insufficient data."); return MNL_CB_ERROR; } stats.stats32 = mnl_attr_get_payload(attr);