linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.5 01/84] cgroup-v1: cgroup_pidlist_next should update position index
@ 2020-03-18 20:51 Sasha Levin
  2020-03-18 20:51 ` [PATCH AUTOSEL 5.5 02/84] cgroup: Iterate tasks that did not finish do_exit() Sasha Levin
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Sasha Levin @ 2020-03-18 20:51 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Vasily Averin, Tejun Heo, Sasha Levin, cgroups

From: Vasily Averin <vvs@virtuozzo.com>

[ 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 <vvs@virtuozzo.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-18 21:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 20:51 [PATCH AUTOSEL 5.5 01/84] cgroup-v1: cgroup_pidlist_next should update position index Sasha Levin
2020-03-18 20:51 ` [PATCH AUTOSEL 5.5 02/84] cgroup: Iterate tasks that did not finish do_exit() Sasha Levin
2020-03-18 20:52 ` [PATCH AUTOSEL 5.5 03/84] iwlwifi: mvm: Do not require PHY_SKU NVM section for 3168 devices Sasha Levin
2020-03-18 20:52 ` [PATCH AUTOSEL 5.5 04/84] clk: imx8mn: Fix incorrect clock defines Sasha Levin
2020-03-18 20:52 ` [PATCH AUTOSEL 5.5 05/84] batman-adv: Don't schedule OGM for disabled interface Sasha Levin
2020-03-18 20:52 ` [PATCH AUTOSEL 5.5 06/84] pinctrl: meson-gxl: fix GPIOX sdio pins Sasha Levin
2020-03-18 20:52 ` [PATCH AUTOSEL 5.5 07/84] pinctrl: imx: scu: Align imx sc msg structs to 4 Sasha Levin
2020-03-18 20:52 ` [PATCH AUTOSEL 5.5 08/84] nfs: add minor version to nfs_server_key for fscache Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).