Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3284698ybb; Tue, 31 Mar 2020 02:05:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv9otPtaCs48+hl10VQb8Sn8cQ1vNThxLsIvNpwIo6PgV3ph+mcjToDzXjZWeDQUkxaOBv1 X-Received: by 2002:aca:ad88:: with SMTP id w130mr1438530oie.82.1585645521443; Tue, 31 Mar 2020 02:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645521; cv=none; d=google.com; s=arc-20160816; b=RdNerDmatCzqMOmTCyLwWwHtkkfGpk3YjO6jOMtoTUvUGo5ojqZHShGIctkr0+C5Hg FgXHIaiY7H5gbkcwStkYRu0r6c6PzbHsf6qHFTSaNnGbuLQgv2vJo3LFY1+KlBJn1yrg hO3C9BQYVHwqrvmBm3DTDLgAD1HIDftxCG2S+OVhr7awQzcolQ/is91CIBYfiqM90WMA ebaWkAXMSdnXQi0UfnxD7/b0uGjkkHIlWGlYtSye2mGMjZlXhiYo0mtqU336ORR3xcxS rpZUjl8bYssxRChuI5gakvP5E/hWboYwADhJ+5e7GlK5UZlKmBwItFMnc5XOaK/p9jhU ZGaQ== 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=XMoY5POKfVpu+Myrgr3dTVfQTZH/aoax+mEMMFY5IFg=; b=JIcpSxmrGDLTI/ip0YTr/z95pkeJ8e9pM4oYSkRDP9PrL9uM6n0wlP0zxpNWCqFbXa GV091kHXvhBafBijbY/mDnUmS92NKsb9bdfckHIdfkMC16EyKf1Z+BaC+UUtZcum6tmA 6xlx4G+PCKB7+jEjJMpOiFJhFnqHJq0US4ahNvnNVBpux3iE26BsxFb3DfCU0985xCy1 6W04+SbQPLC4F4pg+xur/wUNdfXBoDL3xe7Fjpq73TzKgueYIuTXeVwfWHgv9Q4ojIJO +2okC8oJNDSk8NrsHu8rKOZnydV2wLA7S0+v0uzFGnjbENiTy0LG61RSifo2eNh7ffeX pMnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B3kVvNn7; 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 e17si7365653oti.82.2020.03.31.02.05.09; Tue, 31 Mar 2020 02:05:21 -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=B3kVvNn7; 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 S1730984AbgCaJEg (ORCPT + 99 others); Tue, 31 Mar 2020 05:04:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:45172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730662AbgCaJEd (ORCPT ); Tue, 31 Mar 2020 05:04:33 -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 59F91208E0; Tue, 31 Mar 2020 09:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645472; bh=rY05YLwtbtXzyT165RkLIipQqmrwA6WUFyYk2qA7868=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B3kVvNn7ga2laIjpS5HQazm1/aIOTv3BkgJ1fH9D3HXJ0zDFyDEZiRKtmMLehlFHf nsBs0sHXjBgI6qJOcB0FRS7Z+jltbCsARxfixPDOCOLkWoMB9JJHNIRwKUn6gRA2SF 35Uq2oNCzhUTwN8G+4mA8Cw6x9+MCaC3RtaIHnUY= 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 5.5 064/170] cgroup-v1: cgroup_pidlist_next should update position index Date: Tue, 31 Mar 2020 10:57:58 +0200 Message-Id: <20200331085431.290036933@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@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 09f3a413f6f89..84bedb87ae137 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -473,6 +473,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