]> git.baikalelectronics.ru Git - kernel.git/commit
ethtool: fix genlmsg_put() failure handling in ethnl_default_dumpit()
authorMichal Kubecek <mkubecek@suse.cz>
Thu, 9 Jul 2020 10:11:50 +0000 (12:11 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Jul 2020 19:35:33 +0000 (12:35 -0700)
commit58c74c11391516e6555752eb50e8483ff7b98f06
tree6c88d2bceeb96f8bd8a7ab14d7016f6b688981a2
parent1accc7103c3cd7d417d201d44498a4311f727711
ethtool: fix genlmsg_put() failure handling in ethnl_default_dumpit()

If the genlmsg_put() call in ethnl_default_dumpit() fails, we bail out
without checking if we already have some messages in current skb like we do
with ethnl_default_dump_one() failure later. Therefore if existing messages
almost fill up the buffer so that there is not enough space even for
netlink and genetlink header, we lose all prepared messages and return and
error.

Rather than duplicating the skb->len check, move the genlmsg_put(),
genlmsg_cancel() and genlmsg_end() calls into ethnl_default_dump_one().
This is also more logical as all message composition will be in
ethnl_default_dump_one() and only iteration logic will be left in
ethnl_default_dumpit().

Fixes: e9533c9ca90b ("ethtool: default handlers for GET requests")
Reported-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ethtool/netlink.c