Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2458143imd; Fri, 2 Nov 2018 11:45:04 -0700 (PDT) X-Google-Smtp-Source: AJdET5fu3FyYqYhHdQ2cONOqoXA0eZzUg7nsKkhK+ouUqIoo09aaoiSsaxDqcD4jIpCbwJNk8Sby X-Received: by 2002:aa7:8195:: with SMTP id g21-v6mr12769094pfi.71.1541184304130; Fri, 02 Nov 2018 11:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184304; cv=none; d=google.com; s=arc-20160816; b=vUXbF7pdWK3U8FcUz28u0FEYurp5ks6WjtSWJeR0SrkO4Pemdj4VxFuoqqg+s3DXdW czGkcOJeqDh52kNJo14ZAV0JCxnNll3B/jcde7KRB14oIN5cBKebpqjevEr0/mDUu7vN flmumHNxT18VC4j65ne+JrWKO/NdzBzlQlYOyHktGZddDbY6yenQFgr0iWoE1GrE6wIV D17vEoj0xuEry2x8Fc8tZnW2u0I61Lxdj7RAwoB0T94fppJs1+zAjavquxdEEcL8N/H5 c9J1pRSkZayykhN8MwCW9UWreRymppNu4fgVvhKrQ6A9BhXC9Rpp8Zlp6dCOCbXRHwqe Xv8g== 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=BYN20VpRtKsrrdffLXRnfqR4r+XN8pV2bR6fTan2vIs=; b=v2wxqobaG/Jg4WwfTbcUCRscAb8p06w7sMY8wrJdJCRn7g5D3DzK3a4iCXLo1yXgD/ mYSu/wlsQFB0NbRz1mFkt4zis75a4XuVt4Q4cUHYwPOHaJMpiyiTN2bq8ejwVlc2JV4q Kii5O+hnCIjPsNG2+QLVJEvTrMrUvfzzi2mswTDpXh7dQEB0iOu7j3IevrpSIZjQMrSg Ife71AKsM0q2E/sTmtXzKPZA23rN0JBiVJLh9VqYP4A7Y8sy8AtgnX3Hdekg3iY3MDEV ZPp+jc3kLXJJfxO7LyIM19fuQJC5A2I3q2bqwCkEDI+YtThrHE8zJGHCdfDEOtB14tIG QcMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SPdx5dle; 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 d34si4060982pgb.43.2018.11.02.11.44.49; Fri, 02 Nov 2018 11:45:04 -0700 (PDT) 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=SPdx5dle; 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 S1729951AbeKCDv4 (ORCPT + 99 others); Fri, 2 Nov 2018 23:51:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728788AbeKCDvz (ORCPT ); Fri, 2 Nov 2018 23:51:55 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 42B0120847; Fri, 2 Nov 2018 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184223; bh=DaTZCi4Wn3XtLxinhupG3bhxiTM4LjY7+SSrZm8/FmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPdx5dleHo4byVzWHBuZ2LJTRT/ZSxiJ/8+92sgSS22hvJDDQrBli3LypOPZ9A7Tv BV4ujBkX1aGjCLKUP4tFSMusRegd9FJ03VDQsJKz7Ub4Iwe73JFuN9Q2Jy8SMuVovL w24W9ZTGByM6e1eE4WHr4VgjUbyukWOZoJquxDec= 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.18 109/150] net/ipv6: Fix index counter for unicast addresses in in6_dump_addrs Date: Fri, 2 Nov 2018 19:34:31 +0100 Message-Id: <20181102182910.804827657@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@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.18-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 @@ -4930,8 +4930,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, @@ -4940,6 +4940,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; }