Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp778283ybb; Wed, 1 Apr 2020 09:26:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs+hCqXnIyXexSUDgPOvNDFkYotNwxSgF8WjCnhpKCluFmYsM9tXI1iXG0diKpcaWXLPRR3 X-Received: by 2002:a05:6830:1ac1:: with SMTP id r1mr13581915otc.139.1585758404400; Wed, 01 Apr 2020 09:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585758404; cv=none; d=google.com; s=arc-20160816; b=GKcMJDx9wM6Ag+JXbFw2oVTRtlmprQJgyiPODHqParJ0yW5Uq83TzDw+WfjvlfKVG8 Fe5hKFEqfFLwhgJ70Fag9Tql79BGKn9pYb05XrZvmKrXdZepCWtUMmkiljZa1h/4nm4x /yzCoGfg11dJZilziFSWdeSIacyZp3YoVQjBkRwtGNnx8N2q5JLCCxeznpqK1Tcui4uQ Fzhitg5GnM+A8h47Isho8bvtJfBLJozZnQG3Vei7SWiuKhwm881+qS1m7m+cV9yzBu8J AY833u1RyCL1lhiIGl9ECIIJHJ/9Xsn0lOM01FaXJdNM9ivb7+a5/+m08YSvhndHdypH XUtg== 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=UBs2CLUJysOc2g6VEZgfKCAgr/0pqWIhRC2+P5bFjrU=; b=fjCD/VLSoaMd/ZFihLoWB8alRlmFwZk6JRSnzUFrlof7wPz8DYo50+2jduCULbB3gK fj1F+xIYCML5JjUyYxVqp7IWZZ2aKl3+WdiDSVCBRfuDkR4cfUP678ZX2cERocUVpOT/ VaP8gfnvsjlcKiAViXn4Uxwbv/dVWj9HjRt19+u1h1R7MdKrFNXm3WclOV5fZBNxfbtq X7LGN3BZAAVQIe2iNz2FMa2/+8pcuSnRlNWNeMduObNDOLrK6iq+yhNBlXwjFFtanCcp 3AAtTw2JVoJAa5SM3Lpz4fN4H4Cb86vDrg6ploga1PvOT+QirjlUaDMM0Hq4l8SlCbTC yVGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ts01N9tL; 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 w7si1004490otj.223.2020.04.01.09.26.31; Wed, 01 Apr 2020 09:26:44 -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=ts01N9tL; 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 S2387705AbgDAQY0 (ORCPT + 99 others); Wed, 1 Apr 2020 12:24:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:47976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387694AbgDAQYW (ORCPT ); Wed, 1 Apr 2020 12:24:22 -0400 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 7ADED20BED; Wed, 1 Apr 2020 16:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758262; bh=V4XcCi4zI+m4Y89ggKKf+m+BzhB6paEjnpHJR1dUQbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ts01N9tLyCvMoRwyKw5Kp46v2DW+CXuw7EcIiwfTqd4oov3KkOtU4Pr2Makghs7lI nEefhwinf3r4OYMbj8+YdXaLWfFctAMdKyzajUKJb5ql9CoNVuhNgK8YOg8gW4+O69 NrFVAWXn5i5mhcMLEsLC+u44u2DDODs7bOTDNB40= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasily Averin , Tejun Heo , Sasha Levin Subject: [PATCH 4.19 033/116] cgroup-v1: cgroup_pidlist_next should update position index Date: Wed, 1 Apr 2020 18:16:49 +0200 Message-Id: <20200401161546.668252291@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161542.669484650@linuxfoundation.org> References: <20200401161542.669484650@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 db8dd9697238be70a6b4f9d0284cd89f59c0e070 ] if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output. # mount | grep cgroup # dd if=/mnt/cgroup.procs bs=1 # normal output ... 1294 1295 1296 1304 1382 584+0 records in 584+0 records out 584 bytes copied dd: /mnt/cgroup.procs: cannot skip to specified offset 83 <<< generates end of last line 1383 <<< ... and whole last line once again 0+1 records in 0+1 records out 8 bytes copied dd: /mnt/cgroup.procs: cannot skip to specified offset 1386 <<< generates last line anyway 0+1 records in 0+1 records out 5 bytes copied https://bugzilla.kernel.org/show_bug.cgi?id=206283 Signed-off-by: Vasily Averin Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/cgroup/cgroup-v1.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index 51063e7a93c28..c9628b9a41d23 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -501,6 +501,7 @@ static void *cgroup_pidlist_next(struct seq_file *s, void *v, loff_t *pos) */ p++; if (p >= end) { + (*pos)++; return NULL; } else { *pos = *p; -- 2.20.1