]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ip: ipstats: Do not assume length of response attribute payload
authorPetr Machata <petrm@nvidia.com>
Thu, 5 May 2022 15:31:34 +0000 (17:31 +0200)
committerDavid Ahern <dsahern@kernel.org>
Sun, 8 May 2022 15:54:05 +0000 (09:54 -0600)
commitce41750fcc924c377ac3dda1df265e3b27d90a68
tree5197701c9708451be141b29e2c6a63620fc6bc5a
parent2c09c7622afb0b6e4be517af4375182512e5df89
ip: ipstats: Do not assume length of response attribute payload

In Linux kernel commit 794c24e9921f ("net-core: rx_otherhost_dropped to
core_stats"), struct rtnl_link_stats64 got a new member. This change got to
iproute2 through commit bba95837524d ("Update kernel headers").

"ip stats" makes the assumption that the payload of attributes that carry
structures is at least as long as the size of the given structure as
iproute2 knows it. But that will not hold when a newer iproute2 is used
against an older kernel: since such kernel misses some fields on the tail
end of the structure, "ip stats" bails out:

 # ip stats show group link
 1: lo: group link
 Error: attribute payload too shortDump terminated

Instead, be tolerant of responses that are both longer and shorter than
what is expected. Instead of forming a pointer directly into the payload,
allocate the stats structure on the stack, zero it, and then copy over the
portion from the response.

Reported-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/ipstats.c