public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: stable@vger.kernel.org,
	syzbot+a7c1ec5b1d71ceaa5186@syzkaller.appspotmail.com,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 6.2.y] mm/mempolicy: fix use-after-free of VMA iterator
Date: Thu, 27 Apr 2023 10:40:53 +0200	[thread overview]
Message-ID: <2023042738-humorous-handprint-cd6c@gregkh> (raw)
In-Reply-To: <20230424153108.3354538-1-Liam.Howlett@oracle.com>

On Mon, Apr 24, 2023 at 11:31:08AM -0400, Liam R. Howlett wrote:
> [ Upstream commit f4e9e0e69468583c2c6d9d5c7bfc975e292bf188 ]
> 
> set_mempolicy_home_node() iterates over a list of VMAs and calls
> mbind_range() on each VMA, which also iterates over the singular list of
> the VMA passed in and potentially splits the VMA.  Since the VMA iterator
> is not passed through, set_mempolicy_home_node() may now point to a stale
> node in the VMA tree.  This can result in a UAF as reported by syzbot.
> 
> Avoid the stale maple tree node by passing the VMA iterator through to the
> underlying call to split_vma().
> 
> mbind_range() is also overly complicated, since there are two calling
> functions and one already handles iterating over the VMAs.  Simplify
> mbind_range() to only handle merging and splitting of the VMAs.
> 
> Align the new loop in do_mbind() and existing loop in
> set_mempolicy_home_node() to use the reduced mbind_range() function.  This
> allows for a single location of the range calculation and avoids
> constantly looking up the previous VMA (since this is a loop over the
> VMAs).
> 
> Link: https://lore.kernel.org/linux-mm/000000000000c93feb05f87e24ad@google.com/
> Fixes: 66850be55e8e ("mm/mempolicy: use vma iterator & maple state instead of vma linked list")
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> Reported-by: syzbot+a7c1ec5b1d71ceaa5186@syzkaller.appspotmail.com
>   Link: https://lkml.kernel.org/r/20230410152205.2294819-1-Liam.Howlett@oracle.com
> Tested-by: syzbot+a7c1ec5b1d71ceaa5186@syzkaller.appspotmail.com
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit f4e9e0e69468583c2c6d9d5c7bfc975e292bf188)
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> (cherry picked from commit 905e8727c6aca577a8151105a6e0912591649690)

There is no such commit in Linus's tree.  Please be more careful in the
future...


      reply	other threads:[~2023-04-27  8:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-22 16:46 FAILED: patch "[PATCH] mm/mempolicy: fix use-after-free of VMA iterator" failed to apply to 6.2-stable tree gregkh
2023-04-24 15:31 ` [PATCH 6.2.y] mm/mempolicy: fix use-after-free of VMA iterator Liam R. Howlett
2023-04-27  8:40   ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2023042738-humorous-handprint-cd6c@gregkh \
    --to=greg@kroah.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+a7c1ec5b1d71ceaa5186@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox