mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup
@ 2026-11-12 14:01 Adrian Huang (Lenovo)
  2026-11-13  2:37 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Huang (Lenovo) @ 2026-11-12 14:01 UTC (permalink / raw)
  To: Suren Baghdasaryan, Lorenzo Stoakes
  Cc: Andrew Morton, Liam R . Howlett, Vlastimil Babka, Jann Horn,
	Pedro Falcato, linux-mm, linux-kernel, linux-fsdevel, ahuang12,
	Adrian Huang (Lenovo)

Commit 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under
per-vma lock") introduced the possibility of returning -EINTR
from proc_get_vma() when the VMA lookup is interrupted.

When this happens in m_next(), proc_get_vma() returns an error
pointer without updating the position index. Consequently,
seq_read_iter() reports:

  seq_file: buggy .next function m_next did not update position index

The above buggy message is reproduced by the following command:

  # stress-ng --vma 0 -t 60

Update the position index when VMA lookup fails, as required by
the seq_file interface. Also save the original position in
priv->last_pos so that subsequent iteration can restart from
the correct address without skipping or repeating a VMA.

Fixes: 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under per-vma lock")
Signed-off-by: Adrian Huang (Lenovo) <adrianhuang0701@gmail.com>
---
 fs/proc/task_mmu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 22361607020d..164b4efc5e09 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -221,6 +221,16 @@ static struct vm_area_struct *proc_get_vma(struct seq_file *m, loff_t *ppos)
 		if (PTR_ERR(vma) == -EAGAIN && fallback_to_mmap_lock(priv, *ppos))
 			goto retry;
 
+		/*
+		 * seq_file checks that the position advanced before it looks at
+		 * the returned pointer, so an error return that leaves *ppos
+		 * alone is reported as a buggy ->next. Advance it, and keep
+		 * last_pos at the pending position so m_start() would resume
+		 * the lookup from there.
+		 */
+		priv->last_pos = *ppos;
+		(*ppos)++;
+
 		return vma;
 	}
 
-- 
2.43.0


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

* Re: [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup
  2026-11-12 14:01 [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup Adrian Huang (Lenovo)
@ 2026-11-13  2:37 ` Andrew Morton
  2026-11-13  3:13   ` Suren Baghdasaryan
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2026-11-13  2:37 UTC (permalink / raw)
  To: Adrian Huang (Lenovo)
  Cc: Suren Baghdasaryan, Lorenzo Stoakes, Liam R . Howlett,
	Vlastimil Babka, Jann Horn, Pedro Falcato, linux-mm,
	linux-kernel, linux-fsdevel, ahuang12

On Thu, 12 Nov 2026 22:01:01 +0800 "Adrian Huang (Lenovo)" <adrianhuang0701@gmail.com> wrote:

> Commit 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under
> per-vma lock") introduced the possibility of returning -EINTR
> from proc_get_vma() when the VMA lookup is interrupted.

OK, but what's causing the interruption?

> When this happens in m_next(), proc_get_vma() returns an error
> pointer without updating the position index. Consequently,
> seq_read_iter() reports:
> 
>   seq_file: buggy .next function m_next did not update position index
> 
> The above buggy message is reproduced by the following command:
> 
>   # stress-ng --vma 0 -t 60

afaict "stress-ng -t" can send SIGALRM, but mmap_read_lock_killable()
only responds to fatal signals.

So please clarify: exactly what is causing this to happen?



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

* Re: [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup
  2026-11-13  2:37 ` Andrew Morton
@ 2026-11-13  3:13   ` Suren Baghdasaryan
  2026-11-13  3:17     ` Suren Baghdasaryan
  0 siblings, 1 reply; 4+ messages in thread
From: Suren Baghdasaryan @ 2026-11-13  3:13 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Adrian Huang (Lenovo),
	Lorenzo Stoakes, Liam R . Howlett, Vlastimil Babka, Jann Horn,
	Pedro Falcato, linux-mm, linux-kernel, linux-fsdevel, ahuang12

On Thu, Nov 12, 2026 at 6:37 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Thu, 12 Nov 2026 22:01:01 +0800 "Adrian Huang (Lenovo)" <adrianhuang0701@gmail.com> wrote:
>
> > Commit 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under
> > per-vma lock") introduced the possibility of returning -EINTR
> > from proc_get_vma() when the VMA lookup is interrupted.
>
> OK, but what's causing the interruption?
>
> > When this happens in m_next(), proc_get_vma() returns an error
> > pointer without updating the position index. Consequently,
> > seq_read_iter() reports:
> >
> >   seq_file: buggy .next function m_next did not update position index
> >
> > The above buggy message is reproduced by the following command:
> >
> >   # stress-ng --vma 0 -t 60
>
> afaict "stress-ng -t" can send SIGALRM, but mmap_read_lock_killable()
> only responds to fatal signals.
>
> So please clarify: exactly what is causing this to happen?

Also I don't think stress-ng --vma 0 -t 60 command reads maps, smaps
or smaps_rollup files by itself but I might be mistaken. It would be
nice to get more details on how this gets reproduced.

>
>

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

* Re: [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup
  2026-11-13  3:13   ` Suren Baghdasaryan
@ 2026-11-13  3:17     ` Suren Baghdasaryan
  0 siblings, 0 replies; 4+ messages in thread
From: Suren Baghdasaryan @ 2026-11-13  3:17 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Adrian Huang (Lenovo),
	Lorenzo Stoakes, Liam R . Howlett, Vlastimil Babka, Jann Horn,
	Pedro Falcato, linux-mm, linux-kernel, linux-fsdevel, ahuang12

On Thu, Nov 12, 2026 at 7:13 PM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Thu, Nov 12, 2026 at 6:37 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > On Thu, 12 Nov 2026 22:01:01 +0800 "Adrian Huang (Lenovo)" <adrianhuang0701@gmail.com> wrote:
> >
> > > Commit 5631da56c9a8 ("fs/proc/task_mmu: read proc/pid/maps under
> > > per-vma lock") introduced the possibility of returning -EINTR
> > > from proc_get_vma() when the VMA lookup is interrupted.
> >
> > OK, but what's causing the interruption?
> >
> > > When this happens in m_next(), proc_get_vma() returns an error
> > > pointer without updating the position index. Consequently,
> > > seq_read_iter() reports:
> > >
> > >   seq_file: buggy .next function m_next did not update position index
> > >
> > > The above buggy message is reproduced by the following command:
> > >
> > >   # stress-ng --vma 0 -t 60
> >
> > afaict "stress-ng -t" can send SIGALRM, but mmap_read_lock_killable()
> > only responds to fatal signals.
> >
> > So please clarify: exactly what is causing this to happen?
>
> Also I don't think stress-ng --vma 0 -t 60 command reads maps, smaps
> or smaps_rollup files by itself but I might be mistaken. It would be
> nice to get more details on how this gets reproduced.

Just after sending this I found
https://github.com/ColinIanKing/stress-ng/blob/master/stress-vma.c#L536,
so I stand corrected. Still, it would be nice to know how exactly this
issue is reproduced.

>
> >
> >

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

end of thread, other threads:[~2026-11-13  3:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 14:01 [PATCH mm-unstable 1/1] fs/proc/task_mmu: advance seq_file position on interrupted VMA lookup Adrian Huang (Lenovo)
2026-11-13  2:37 ` Andrew Morton
2026-11-13  3:13   ` Suren Baghdasaryan
2026-11-13  3:17     ` Suren Baghdasaryan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®