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=f7960c5d74068aec075758718a2779d09235d5d5;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 # Conflicts: # src/netlink.c --- diff --git a/src/netlink.c b/src/netlink.c index b5ae3bd2..29cd383c 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -357,11 +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) { - char errbuf[1024]; - ERROR("netlink plugin: link_filter_cb: IFLA_STATS64 mnl_attr_validate2 " - "failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + 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); @@ -375,11 +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) { - char errbuf[1024]; - ERROR("netlink plugin: link_filter_cb: IFLA_STATS mnl_attr_validate2 " - "failed: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + 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);