Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp881273pxk; Thu, 17 Sep 2020 20:12:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUjGLrkqihHCrK1+8Q/drBeLcMZsjSSzdjeJ0upXcASqZJM/axS1E6cghmR1E7Gm7Rf8XW X-Received: by 2002:a05:6402:13d3:: with SMTP id a19mr35653932edx.255.1600398778574; Thu, 17 Sep 2020 20:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398778; cv=none; d=google.com; s=arc-20160816; b=hMlgeZ50dlVzC9g9B2KOneH190xr5CV+bXI+RIBHrE23F3kcKnExJ2IgXE6GgJPgLs VgVOfOoFFapipetLNeUxG4ceuPL1VYbW8aaUpfikHClCcnF3UCIOVZXEBFk4G2bhwA8+ tpEe2ZObkQktTZC08SlivlHN8W7fEjsXwZfrQXv4el2TyxPqefSNgL/Eyy/UvkudNHw3 fOa/M4XQxSFdFSxxeBOzPXFx+RNmZ9eeZE7OO1n+H/4oo47bfn/V1Kd3x476jdiA4m4F PJnRp36YmgU3pfEpjQr/bDvAtkWRYwJQrKe2M/Hi/t/DYEWBjBWnjvYwZZr6PXrGBg/Y Tveg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eGSkIwcRguE08GK4cthm1inmAOl/IVcJmNfu3QIkcE4=; b=I2oB1TiYLlcX2EqwYKK22BpwjQ/ZMoTJOGxr0ZRU8pEIkXTaxzSedZ9l7D9re9I7Db 6LlMFKYoldfJqviMEk1fEoUkGM5K00lBa4V9+aAqjf9u3NVlVdk+MgRBqzZ7JAXb835g ca6krYUXn3QF68dn+7muy9InSbQpcVHDrp/H/5JsdVux/WdqtE+3hvUb719FlwCVy3uA ZHcyYRfaIVLX3Hz7g8xRFsxMOtTFNwutqtxf//GF2JWpykCmXW7QKvXsXlb0yx6DtcNl VK936Vuztfi/XH1U5H6rjD718E+8Ws37UCLa7exRTTZE2fX8eGRGzgoAo9BPYb93v5G9 DoxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1bhAPjzE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si1231102ejj.566.2020.09.17.20.12.35; Thu, 17 Sep 2020 20:12:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1bhAPjzE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730664AbgIRDKj (ORCPT + 99 others); Thu, 17 Sep 2020 23:10:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:48438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgIRCCu (ORCPT ); Thu, 17 Sep 2020 22:02:50 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A47DE221EC; Fri, 18 Sep 2020 02:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394570; bh=v+W8/awZS8rhO7aYxuU68FA7fq9eALWPr7DftF63EQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1bhAPjzE8b4FF0a4XK5t/JHRiWwgfIYobhBHYGY+x8X2jJBLdcBXPS+akoz9Mz3D3 di74Qtfmu1HDBMePaJnQCiVfw+4wSDwY8SCC76/oPVUvv1V4UJNWa1ehSZMjScXbSa 2W+fuZngYu8b/YJ+YrWfAQEoph7DX9hGX36NYwK0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vasily Averin , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 082/330] ipv6_route_seq_next should increase position index Date: Thu, 17 Sep 2020 21:57:02 -0400 Message-Id: <20200918020110.2063155-82-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vasily Averin [ Upstream commit 4fc427e0515811250647d44de38d87d7b0e0790f ] if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output. https://bugzilla.kernel.org/show_bug.cgi?id=206283 Signed-off-by: Vasily Averin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/ip6_fib.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 7a0c877ca306c..7662de1bd7fd2 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -2474,14 +2474,13 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos) struct net *net = seq_file_net(seq); struct ipv6_route_iter *iter = seq->private; + ++(*pos); if (!v) goto iter_table; n = rcu_dereference_bh(((struct fib6_info *)v)->fib6_next); - if (n) { - ++*pos; + if (n) return n; - } iter_table: ipv6_route_check_sernum(iter); @@ -2489,8 +2488,6 @@ iter_table: r = fib6_walk_continue(&iter->w); spin_unlock_bh(&iter->tbl->tb6_lock); if (r > 0) { - if (v) - ++*pos; return iter->w.leaf; } else if (r < 0) { fib6_walker_unlink(net, &iter->w); -- 2.25.1