diff mbox series

mm: /proc/pid/smaps_rollup: fix no vma's null-deref

Message ID 20221003224531.1930646-1-sethjenkins@google.com (mailing list archive)
State New
Headers show
Series mm: /proc/pid/smaps_rollup: fix no vma's null-deref | expand

Commit Message

Seth Jenkins Oct. 3, 2022, 10:45 p.m. UTC
From: Seth Jenkins <sethjenkins@google.com>

Commit 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value
seq_file") introduced a null-deref if there are no vma's in the task in
show_smaps_rollup.

Fixes: 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value seq_file")
Cc: stable@vger.kernel.org
Signed-off-by: Seth Jenkins <sethjenkins@google.com>
---
 fs/proc/task_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexey Dobriyan Oct. 4, 2022, 12:53 p.m. UTC | #1
On Mon, Oct 03, 2022 at 06:45:31PM -0400, FirstName LastName wrote:
> From: Seth Jenkins <sethjenkins@google.com>
> 
> Commit 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value
> seq_file") introduced a null-deref if there are no vma's in the task in
> show_smaps_rollup.
> 
> Fixes: 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value seq_file")
> Cc: stable@vger.kernel.org
> Signed-off-by: Seth Jenkins <sethjenkins@google.com>

> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -969,7 +969,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
>  		vma = vma->vm_next;
>  	}
>  
> -	show_vma_header_prefix(m, priv->mm->mmap->vm_start,
> +	show_vma_header_prefix(m, priv->mm->mmap ? priv->mm->mmap->vm_start : 0,
>  			       last_vma_end, 0, 0, 0, 0);
>  	seq_pad(m, ' ');
>  	seq_puts(m, "[rollup]\n");

Reviewed-by: Alexey Dobriyan <adobriyan@gmail.com>
Tested-by: Alexey Dobriyan <adobriyan@gmail.com>

Now I know how to create stable process without address space.
Andrew Morton Oct. 4, 2022, 6:46 p.m. UTC | #2
On Mon,  3 Oct 2022 18:45:31 -0400 FirstName LastName <sethjenkins@google.com> wrote:

> From: Seth Jenkins <sethjenkins@google.com>
> 
> Commit 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value
> seq_file") introduced a null-deref if there are no vma's in the task in
> show_smaps_rollup.
> 
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -969,7 +969,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
>  		vma = vma->vm_next;
>  	}
>  
> -	show_vma_header_prefix(m, priv->mm->mmap->vm_start,
> +	show_vma_header_prefix(m, priv->mm->mmap ? priv->mm->mmap->vm_start : 0,
>  			       last_vma_end, 0, 0, 0, 0);
>  	seq_pad(m, ' ');
>  	seq_puts(m, "[rollup]\n");

The current mm tree is very different here.  In fact the bug might not
exist any more.  Please take a look at the mm-stable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm?

If no fixes are needed in mm-stable then I guess the process is to
propose this patch to the stable tree maintainers.
Seth Jenkins Oct. 4, 2022, 9:05 p.m. UTC | #3
I concur, mm-stable looks fine to me as well.

Jann and I conversed today and the tentative decision since this isn't
considered a high-priority security bug is to wait for maple tree to
merge into Linus's branch before submitting this patch to stable.

On Tue, Oct 4, 2022 at 2:46 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Mon,  3 Oct 2022 18:45:31 -0400 FirstName LastName <sethjenkins@google.com> wrote:
>
> > From: Seth Jenkins <sethjenkins@google.com>
> >
> > Commit 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value
> > seq_file") introduced a null-deref if there are no vma's in the task in
> > show_smaps_rollup.
> >
> > --- a/fs/proc/task_mmu.c
> > +++ b/fs/proc/task_mmu.c
> > @@ -969,7 +969,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
> >               vma = vma->vm_next;
> >       }
> >
> > -     show_vma_header_prefix(m, priv->mm->mmap->vm_start,
> > +     show_vma_header_prefix(m, priv->mm->mmap ? priv->mm->mmap->vm_start : 0,
> >                              last_vma_end, 0, 0, 0, 0);
> >       seq_pad(m, ' ');
> >       seq_puts(m, "[rollup]\n");
>
> The current mm tree is very different here.  In fact the bug might not
> exist any more.  Please take a look at the mm-stable branch at
> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm?
>
> If no fixes are needed in mm-stable then I guess the process is to
> propose this patch to the stable tree maintainers.
>
diff mbox series

Patch

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 4e0023643f8b..1e7bbc0873a4 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -969,7 +969,7 @@  static int show_smaps_rollup(struct seq_file *m, void *v)
 		vma = vma->vm_next;
 	}
 
-	show_vma_header_prefix(m, priv->mm->mmap->vm_start,
+	show_vma_header_prefix(m, priv->mm->mmap ? priv->mm->mmap->vm_start : 0,
 			       last_vma_end, 0, 0, 0, 0);
 	seq_pad(m, ' ');
 	seq_puts(m, "[rollup]\n");