Skip to content

Commit

Permalink
netlink plugin: Use of less strict rules in link_filter_cb()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Pavel Rochnyack committed May 7, 2018
1 parent 4ee5bff commit 48a9888
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/netlink.c
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 48a9888

Please sign in to comment.