Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp35814imu; Thu, 8 Nov 2018 14:18:00 -0800 (PST) X-Google-Smtp-Source: AJdET5eg5IOf0qFXeLtBF+5pUF3w3XWi57/HZIxhaClrYZQF1+pNS5J/JemTYFB2w4FCaz6cFxs9 X-Received: by 2002:a63:f006:: with SMTP id k6mr5323458pgh.259.1541715480538; Thu, 08 Nov 2018 14:18:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541715480; cv=none; d=google.com; s=arc-20160816; b=kY4AE0NpJa6jJcQ8uUWtwJ+BMxcYPMmttMWjBwhiX1cBmAWareJBtIsm6Hi1U6XJ7v Lrq4FhMy6cHhuqN+Pli8InLiaLJaKoMwhTmWvLPF77AFNs7JlySj6PHnJOUAXvPUrVU0 Eyf10jdkTpNCoXic8jdskGhU5JE9d6pc+2B2/Ns3WeKtf/+liG4lFo5EhV59MGTQemPZ hMJ36u4LYPa8FYlx967gz9WsIfvYV/mKusx0P7Vsyqrws3xtrVwTpLg5H5S/1HJ3bNcJ hPi0G9ZgM4v3m39f9wzsADGsmqBRJH9D7kRSOZ2MxtjC7cHxEagDbIx4FFnsvdBAk0b1 Z9rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HZRfXDcZHxcBXGvmqillhveWZzMyfd4/ZViMg/O5A/s=; b=0NIFAMoVoWHIqT632TPNqbaccYFmKg8Xawx6fef+b1tm2zHYyhrg3576GSuzExOAzn vNT5TvoQcrj/5uETNaRKatL1LQyL+z9wBoh8nf0GyHBP/aLoK4FLtwKcRTJs4EWvvhF9 CsjiIXUmuuIJNe0nOfuMpJiZtWgbpaGotq9gJngmT1frA9DY/BYnl144LMeVwqSenRuU tdTBYTuxiG2E4BFmuDucNgw8JEA0T8A8FiHIRqF41j1h7x+iT+fdzgcPe+W0EpooyoCb yD9AoDhxro07zSiyAc25CPpCU5TxUTayzv+Ez4AUWWv4HZL7zF/5OwYo5+cswoFCfNaH FlNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L+L2cP1x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u184si4936663pgd.93.2018.11.08.14.17.44; Thu, 08 Nov 2018 14:18:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L+L2cP1x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732377AbeKIHpJ (ORCPT + 99 others); Fri, 9 Nov 2018 02:45:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:38478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730686AbeKIHpJ (ORCPT ); Fri, 9 Nov 2018 02:45:09 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C7682089F; Thu, 8 Nov 2018 22:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714858; bh=F7F14FKZMRw7+mpynJLruEE/ZIOnYFqwpn6cF4t6z6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+L2cP1x+FY5Ygz3m8vZ1tX5OJ9rRWYjTJDOf+vj1CmOdratdz8YmE8/zUfe/Drc0 xQqEj9rybEKoPf+FtfT86O21UOxNDuBCei7VRnSD+Cc3VXlFHrCiwSw52bOqS5OOP7 S26d3X+lWXSl2uF4kj6H5dRdT7rZ6dutLgjfAOdE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , "David S. Miller" Subject: [PATCH 4.9 139/171] net/ipv6: Fix index counter for unicast addresses in in6_dump_addrs Date: Thu, 8 Nov 2018 13:51:49 -0800 Message-Id: <20181108215137.084230092@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215127.257643509@linuxfoundation.org> References: <20181108215127.257643509@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Ahern [ Upstream commit 4ba4c566ba8448a05e6257e0b98a21f1a0d55315 ] The loop wants to skip previously dumped addresses, so loops until current index >= saved index. If the message fills it wants to save the index for the next address to dump - ie., the one that did not fit in the current message. Currently, it is incrementing the index counter before comparing to the saved index, and then the saved index is off by 1 - it assumes the current address is going to fit in the message. Change the index handling to increment only after a succesful dump. Fixes: 502a2ffd7376a ("ipv6: convert idev_list to list macros") Signed-off-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/addrconf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -4721,8 +4721,8 @@ static int in6_dump_addrs(struct inet6_d /* unicast address incl. temp addr */ list_for_each_entry(ifa, &idev->addr_list, if_list) { - if (++ip_idx < s_ip_idx) - continue; + if (ip_idx < s_ip_idx) + goto next; err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, @@ -4731,6 +4731,8 @@ static int in6_dump_addrs(struct inet6_d if (err < 0) break; nl_dump_check_consistent(cb, nlmsg_hdr(skb)); +next: + ip_idx++; } break; }