Re: [PATCH 1/2] fs/proc/task_mmu: change lock_vma_range() to return error code

From: Suren Baghdasaryan

Date: Tue Jun 09 2026 - 13:14:41 EST


On Tue, Jun 9, 2026 at 1:28 AM Lorenzo Stoakes <ljs@xxxxxxxxxx> wrote:
>
> On Fri, Jun 05, 2026 at 06:57:28PM -0700, Suren Baghdasaryan wrote:
> > To correctly propagate error code from lock_vma_range(), change it to
> > return the error code instead of the boolean. This simplifies error
> > propagation code.
> >
> > Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
>
> Logic LGTM, couple nits below, but:
>
> Reviewed-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>

Thanks!

>
> > ---
> > fs/proc/task_mmu.c | 16 +++++++++-------
> > 1 file changed, 9 insertions(+), 7 deletions(-)
> >
> > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> > index d32408f7cd5e..023422fcee12 100644
> > --- a/fs/proc/task_mmu.c
> > +++ b/fs/proc/task_mmu.c
> > @@ -162,13 +162,13 @@ static void unlock_ctx_vma(struct proc_maps_locking_ctx *lock_ctx)
> > }
> > }
> >
> > -static inline bool lock_vma_range(struct seq_file *m,
> > - struct proc_maps_locking_ctx *lock_ctx)
> > +static inline int lock_vma_range(struct seq_file *m,
>
> Could drop the unnecessary inline here while we're here.

Will do.

>
> > + struct proc_maps_locking_ctx *lock_ctx)
> > {
> > rcu_read_lock();
> > reset_lock_ctx(lock_ctx);
> >
> > - return true;
> > + return 0;
> > }
> >
> > static inline void unlock_vma_range(struct proc_maps_locking_ctx *lock_ctx)
> > @@ -245,10 +245,10 @@ static inline void unlock_ctx_mm(struct proc_maps_locking_ctx *lock_ctx)
> > mmap_read_unlock(lock_ctx->mm);
> > }
> >
> > -static inline bool lock_vma_range(struct seq_file *m,
> > +static inline int lock_vma_range(struct seq_file *m,
>
> Same comment as above.
>
> > struct proc_maps_locking_ctx *lock_ctx)
> > {
> > - return lock_ctx_mm(lock_ctx) == 0;
> > + return lock_ctx_mm(lock_ctx);
> > }
> >
> > static inline void unlock_vma_range(struct proc_maps_locking_ctx *lock_ctx)
> > @@ -311,6 +311,7 @@ static void *m_start(struct seq_file *m, loff_t *ppos)
> > struct proc_maps_locking_ctx *lock_ctx;
> > loff_t last_addr = *ppos;
> > struct mm_struct *mm;
> > + int err;
> >
> > /* See m_next(). Zero at the start or after lseek. */
> > if (last_addr == SENTINEL_VMA_END)
> > @@ -328,11 +329,12 @@ static void *m_start(struct seq_file *m, loff_t *ppos)
> > return NULL;
> > }
> >
> > - if (!lock_vma_range(m, lock_ctx)) {
> > + err = lock_vma_range(m, lock_ctx);
> > + if (err) {
> > mmput(mm);
> > put_task_struct(priv->task);
> > priv->task = NULL;
> > - return ERR_PTR(-EINTR);
> > + return ERR_PTR(err);
> > }
> >
> > /*
> >
> > base-commit: e178a530a81621a29efbca49b3b78202a18236e4
> > --
> > 2.54.0.1032.g2f8565e1d1-goog
> >