From: Arthur Gautier <ba...@gandi.net>

This commit fixes a regression in AF_INET/RTM_GETADDR and
AF_INET6/RTM_GETADDR. The AF_UNSPEC/RTM_GETADDR was not affected by this as
rtnl_dump_all would just hide the errno.

Before this commit, the kernel would stop dumping addresses once the first
skb was full and end the stream with NLMSG_DONE(-EMSGSIZE). The callback
should be kept alive as the userspace is expected to call back with a new
empty skb.

Fixes: d7e38611b81e ("net/ipv4: Put target net when address dump fails due to 
bad attributes")
Fixes: 242afaa6968c ("net/ipv6: Put target net when address dump fails due to 
bad attributes")

Cc: David Ahern <dsah...@gmail.com>
Cc: "David S . Miller" <da...@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Arthur Gautier <ba...@gandi.net>
---
 net/netlink/af_netlink.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 3c023d6120f65..0a48bca246bc4 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2245,6 +2245,15 @@ static int netlink_dump(struct sock *sk)
                cb->extack = NULL;
        }
 
+       /* Should the dump method run out of space, we have to
+        * keep the dumper running until completion.
+        * Just ignore the error, userspace should call back with a
+        * new skb until dump is complete
+        */
+       if (nlk->dump_done_errno == -EMSGSIZE) {
+               nlk->dump_done_errno = skb->len;
+       }
+
        if (nlk->dump_done_errno > 0 ||
            skb_tailroom(skb) < nlmsg_total_size(sizeof(nlk->dump_done_errno))) 
{
                mutex_unlock(nlk->cb_mutex);
-- 
2.20.1

Reply via email to