Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1621101ybv; Fri, 21 Feb 2020 00:26:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyrn8fLK1661bGGGe7llmcV/H2CAQNLmq52WCmbuj6hmU07sr6Vnd607VZyeIfCgI8piOHG X-Received: by 2002:a9d:58cb:: with SMTP id s11mr27952516oth.55.1582273607146; Fri, 21 Feb 2020 00:26:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273607; cv=none; d=google.com; s=arc-20160816; b=Trd56C+A6PveHGUMWvuYetHeRtYIEfft0i4R6fFIVpIvzvQUWlDQ+9f1vNWfvGKhIQ mAcwcpq7/Lr6mof8J7YG4sce5EsGvUyUNvWT1X82vASjBcIqzEQw7CT6DbSaeCOTy/VI vNt4Z2CXVzo7t8lw1S6LH5cOeW7V9SPZPpF1Jc51Or82y9VSrMHEPDWaIiSee8wzghzu 0Rfc2j8GIRofLPxVkK8CKjYTlMJjJ3cvYkrlx0sD2a+emFj1Ds6TUdw3KxPI9NT3Zr2C qBWlPnqmjT9kHi2gm0ZDcjBk8kKPiizpwUTa31I2jOWUES91Uo8ygBoupNv0lB1hNtxx PKBg== 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=Z4JqkUW22WqBwcaU5OW2rJa9JuG857xZk+GKTbMs6Ws=; b=HA9jdbJNzuAUG/fd8ixUWDMwMj9YBOm1AsjfWT7iBILXLA++407yBACX+co3ge+3Zo XGZ2hMkldnXidyEJXlB4rXdRhSEefCRunl2TEhOabp768XLbpW1A15zXH7cHtOTkSrAn tGdkdfY2ODlehJo19Y0aFvsnlShNmdDd9GEhwU5bVsIkg+9SSpdCjDmpNiMgc13RMPPn PkuxrkO+CKZAhy8+uGLTTOEZ7RpumWn2rJSO1tzdBdJ310ZaIdyvf7BUntHxl+882+l4 vLpPX19x5OoByCNsrTAc4poL3rpHfEa4HTA/g7/VihcjRJHieT0pWI108ba9qpGYs8XW A10A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1KVuvKbh; 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 x72si451703oia.194.2020.02.21.00.26.35; Fri, 21 Feb 2020 00:26:47 -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=1KVuvKbh; 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 S2388841AbgBUIZ4 (ORCPT + 99 others); Fri, 21 Feb 2020 03:25:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:37570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388334AbgBUIYz (ORCPT ); Fri, 21 Feb 2020 03:24:55 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 C4499246A6; Fri, 21 Feb 2020 08:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273495; bh=7P2vlFybEQGvQnGZvdak6Xt5WNMRnhmHfVS2Glgdc78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1KVuvKbhHReysdM7Kbez3KklFd/IRHiIcMHNjs/F/PS+JngjOExfKQ4T54ffDLMDD SvLrYA7vxvhIkGHazqQ+Qx+KS7ddsy6sJ7f4H2xqHJrrtYUKVXYOKN51McJSenTZ9H o2jZ6WWjKdLnq0h4taJslbhNo1Z4vtALY+vBfIKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasily Averin , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.19 168/191] bpf: map_seq_next should always increase position index Date: Fri, 21 Feb 2020 08:42:21 +0100 Message-Id: <20200221072310.880540739@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Vasily Averin [ Upstream commit 90435a7891a2259b0f74c5a1bc5600d0d64cba8f ] If seq_file .next fuction does not change position index, read after some lseek can generate an unexpected output. See also: https://bugzilla.kernel.org/show_bug.cgi?id=206283 v1 -> v2: removed missed increment in end of function Signed-off-by: Vasily Averin Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/eca84fdd-c374-a154-d874-6c7b55fc3bc4@virtuozzo.com Signed-off-by: Sasha Levin --- kernel/bpf/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index dc9d7ac8228db..c04815bb15cc1 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -198,6 +198,7 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos) void *key = map_iter(m)->key; void *prev_key; + (*pos)++; if (map_iter(m)->done) return NULL; @@ -210,8 +211,6 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos) map_iter(m)->done = true; return NULL; } - - ++(*pos); return key; } -- 2.20.1