Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp47846imu; Thu, 8 Nov 2018 14:32:08 -0800 (PST) X-Google-Smtp-Source: AJdET5fugiTutZIotksTeiIlk/1w1fbm7rxF0YbjxsBw8TvM0kmzx4Pud5r+XK+8WEphwW+s4B4n X-Received: by 2002:a17:902:4222:: with SMTP id g31-v6mr6308583pld.236.1541716328471; Thu, 08 Nov 2018 14:32:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716328; cv=none; d=google.com; s=arc-20160816; b=iXNuBv2XmfZ+SMCH/0xCc+wR2XCkhsKYVfYjH2nJ94pjhl54z8+VhewsrMXeJwHvFB MY4dSqzSxbJBVQNTRW0NHuKpFuiDc++7GfGIG3HKBaipw8E1YXjpiTicL7O7exRSODLI GXMWdUj2QPG1EtJrA1Ncr98WczE1I0Zn0iivpguQgY11nXJQwQ9JwDZNUsxOFKxrGdNr w39AR5+YFkHl91zgrY85ERcFgn+AJnr2Dopbs5SsGjXSaH16EYnz1u923NlNDWgPcQz4 NreF0EIu+CxyvekK3bHeiMrHPlUYZ5d6wpW3AE5bEg3d2IktSlqVBjf/n7pRub5Onj0q TiVw== 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=93Ln06/rWljBYWDliFGwpgeeVjOoa5ORxRhkPF29pa8=; b=rgly3k0l8MOT2xVDwiCwLitmC76cuameG6nf3DiH9wYSLhxj8S5PVIMPacyoozlvHC 5Zl+0V9Hbr3BaSM5c/PPz44TMnNl2Brh+JnlPIdaHiyFnJJAarxQfvryATSfSIuDquri kJcglk+7mslmIysoXrXCF+oKi02ELrKlfvBGpABzXL8pclr8Yt1P8YCZKgkcfK9KSTSI H3FFC0k14gU4drm3TqS3Z5K5uM1pxkcj4h2NNIbfcRTpT4ISXrwr2CyJQVLS8za7JXGC LqUErXUm7ppXIhTvOOhs4I774pAv37CwGxHGpuHZh1XzX4EoGjVrSXWi8ZRe3j/cjLnB Vw3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kv6PL7mT; 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 r24-v6si4362764pgv.380.2018.11.08.14.31.52; Thu, 08 Nov 2018 14:32:08 -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=Kv6PL7mT; 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 S1730630AbeKIHiO (ORCPT + 99 others); Fri, 9 Nov 2018 02:38:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:57308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729667AbeKIHiN (ORCPT ); Fri, 9 Nov 2018 02:38:13 -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 A358420818; Thu, 8 Nov 2018 22:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714444; bh=S3ef1LPLFvyjbmvhG8K8VaJuSc0b4ike0iJEPXOxWO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kv6PL7mTlk6ldMXj9Pfa73NRy/nEpai2OG5+iqIWLLZ4Qdk27yQUKkCnp4x6nUST+ VKJiAZRaJSw56s6V57qhmwr6ByL5xYtkNJRpAGYvFFb29lF57QWGwjCswp6C1+f6lO oHdoGyJlkzQJIfOtW4Vqqtz/9hEL5mWPKVmeC/EE= 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.4 092/114] net/ipv6: Fix index counter for unicast addresses in in6_dump_addrs Date: Thu, 8 Nov 2018 13:51:47 -0800 Message-Id: <20181108215109.105708903@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@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.4-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 @@ -4439,8 +4439,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, @@ -4449,6 +4449,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; }