tipc: fix infinite loop when dumping link monitor summary
authorTung Nguyen <tung.q.nguyen@dektech.com.au>
Tue, 17 Apr 2018 19:58:27 +0000 (21:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Jun 2018 19:02:43 +0000 (04:02 +0900)
commit3f64c0c502ef050846c6dc1b56a9510afee53328
tree91150754dc67bd399e8e46ba90b0ebbeb97b02d5
parent9d5e2d69705fed4ab527f5a283b90ae602f4e0fd
tipc: fix infinite loop when dumping link monitor summary

[ Upstream commit 36a50a989ee8267588de520b8704b85f045a3220 ]

When configuring the number of used bearers to MAX_BEARER and issuing
command "tipc link monitor summary", the command enters infinite loop
in user space.

This issue happens because function tipc_nl_node_dump_monitor() returns
the wrong 'prev_bearer' value when all potential monitors have been
scanned.

The correct behavior is to always try to scan all monitors until either
the netlink message is full, in which case we return the bearer identity
of the affected monitor, or we continue through the whole bearer array
until we can return MAX_BEARERS. This solution also caters for the case
where there may be gaps in the bearer array.

Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/tipc/monitor.c
net/tipc/node.c