From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16981C2D0E8 for ; Tue, 31 Mar 2020 09:04:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E02F920675 for ; Tue, 31 Mar 2020 09:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645475; bh=rY05YLwtbtXzyT165RkLIipQqmrwA6WUFyYk2qA7868=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=v6YNFTvOu6OkByAGWJJRXdk4JnPgtrSBmyoXi6zord80FYvV0NyUi7N6CXNUYhGyx xJukddtF3yYXZM/I5axPCxIqR7yqg4i/E+AJGLl5XbtCkoDqHLZbz8rhWOsfaGSkkH 6aH58hBxrNINpsZ7TqUExQrMOmAacePysM2oBoL8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730974AbgCaJEe (ORCPT ); Tue, 31 Mar 2020 05:04:34 -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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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