From: Liam Howlett <liam.howlett@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>,
syzbot <syzbot+ee1fdd8dcc770a3a169a@syzkaller.appspotmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"syzkaller-bugs@googlegroups.com"
<syzkaller-bugs@googlegroups.com>,
Michel Lespinasse <michel@lespinasse.org>
Cc: "maple-tree@lists.infradead.org" <maple-tree@lists.infradead.org>
Subject: Re: [syzbot] general protection fault in vma_interval_tree_remove
Date: Thu, 19 May 2022 02:03:53 +0000 [thread overview]
Message-ID: <20220519020341.rr3s6b4dr7o36cqb@revolver> (raw)
In-Reply-To: <20220516175958.cswumupmeddptzdb@revolver>
[-- Attachment #1: Type: text/plain, Size: 1726 bytes --]
* Liam R. Howlett <Liam.Howlett@Oracle.com> [220516 13:59]:
> * Andrew Morton <akpm@linux-foundation.org> [220514 16:50]:
> > On Sat, 14 May 2022 13:18:26 -0700 syzbot <syzbot+ee1fdd8dcc770a3a169a@syzkaller.appspotmail.com> wrote:
> >
> > > syzbot has found a reproducer for the following issue on:
> > >
> > > HEAD commit: 1e1b28b936ae Add linux-next specific files for 20220513
> > > git tree: linux-next
> > > console+strace: https://syzkaller.appspot.com/x/log.txt?x=11da21b9f00000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=e4eb3c0c4b289571
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=ee1fdd8dcc770a3a169a
> > > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=142757f1f00000
> > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17cf0966f00000
> >
> > Thanks.
> >
> > So it was there on April 28 and it's there now. Liam, do you think
> > anything in the mapletree changes could have perturbed the interval
> > tree handling?
>
> It is certainly possible, these two trees are intertwined so much. One
> area that sticks out as a possibility is vma_expand(). I created a
> vma_expand() function to handle growing a vma and potentially removing
> the next vma. I do some interval tree modifications in there.
>
> I'll add it to my list of items to look at.
This was my bug. I reused a pointer that wasn't reused in this function
until I altered the error path in this commit.
Please apply this patch to the maple tree series to fix "mm/mmap: use
advanced maple tree API for mmap_region()"
Thanks,
Liam
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mm-mmap-Fix-advanced-maple-tree-API-for-mmap_region.patch --]
[-- Type: text/x-diff; name="0001-mm-mmap-Fix-advanced-maple-tree-API-for-mmap_region.patch", Size: 2000 bytes --]
From 0a381753d0584ca02532889a5e84c482ecbc1b9a Mon Sep 17 00:00:00 2001
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
Date: Wed, 13 Apr 2022 23:07:16 -0700
Subject: [PATCH] mm/mmap: Fix advanced maple tree API for mmap_region()
Overwriting next pointer in mmap_region() breaks the error path in a
future patch.
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
mm/mmap.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index f705e68931ce..9e0c657c265d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1765,7 +1765,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma = NULL;
- struct vm_area_struct *prev, *next;
+ struct vm_area_struct *next, *prev, *merge;
pgoff_t pglen = len >> PAGE_SHIFT;
unsigned long charged = 0;
unsigned long end = addr + len;
@@ -1883,19 +1883,17 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
* as we may succeed this time.
*/
if (unlikely(vm_flags != vma->vm_flags && prev)) {
- next = vma_merge(mm, prev, vma->vm_start, vma->vm_end, vma->vm_flags,
+ merge = vma_merge(mm, prev, vma->vm_start, vma->vm_end, vma->vm_flags,
NULL, vma->vm_file, vma->vm_pgoff, NULL, NULL_VM_UFFD_CTX, NULL);
- if (next) {
+ if (merge) {
/* ->mmap() can change vma->vm_file and fput the original file. So
* fput the vma->vm_file here or we would add an extra fput for file
* and cause general protection fault ultimately.
*/
fput(vma->vm_file);
vm_area_free(vma);
- vma = prev;
- /* Update vm_flags and possible addr to pick up the change. We don't
- * warn here if addr changed as the vma is not linked by vma_link().
- */
+ vma = merge;
+ /* Update vm_flags to pick up the change. */
addr = vma->vm_start;
vm_flags = vma->vm_flags;
goto unmap_writable;
--
2.35.1
next prev parent reply other threads:[~2022-05-19 2:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 12:06 [syzbot] general protection fault in vma_interval_tree_remove syzbot
2022-05-14 20:18 ` syzbot
2022-05-14 20:50 ` Andrew Morton
2022-05-16 18:00 ` Liam Howlett
2022-05-19 2:03 ` Liam Howlett [this message]
2022-05-19 5:18 ` Dmitry Vyukov
2022-05-15 0:09 ` syzbot
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=20220519020341.rr3s6b4dr7o36cqb@revolver \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=michel@lespinasse.org \
--cc=syzbot+ee1fdd8dcc770a3a169a@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).