linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: linmiaohe <linmiaohe@huawei.com>
To: "akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: mmap: Fix general protection fault in unlink_file_vma()
Date: Wed, 7 Oct 2020 02:51:15 +0000	[thread overview]
Message-ID: <d06c6c0652e64ae79a55951e94df3610@huawei.com> (raw)

Friendly ping.
> The syzbot reported the below general protection fault:
>
> general protection fault, probably for non-canonical address
> 0xe00eeaee0000003b: 0000 [#1] PREEMPT SMP KASAN
> KASAN: maybe wild-memory-access in range [0x00777770000001d8-0x00777770000001df]
> CPU: 1 PID: 10488 Comm: syz-executor721 Not tainted 5.9.0-rc3-syzkaller #0
>
> It's because the ->mmap() callback can change vma->vm_file and fput the original file. But the commit d70cec898324 ("mm: mmap: merge vma after
> call_mmap() if possible") failed to catch this case and always fput() the original file, hence add an extra fput().
>
> [ Thanks Hillf for pointing this extra fput() out. ]
>
> @@ -1815,7 +1815,11 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
>  			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);
>  			if (merge) {
> -				fput(file);
> +				/* ->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 = merge;
>  				/* Update vm_flags and possible addr to pick up the change. We don't
> --
> 2.19.1
>


             reply	other threads:[~2020-10-07  2:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  2:51 linmiaohe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-10-09  6:39 linmiaohe
2020-10-08  7:17 linmiaohe
2020-10-09  4:23 ` Andrew Morton
2020-09-16  9:07 Miaohe Lin
2020-10-07 19:04 ` Andrew Morton

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=d06c6c0652e64ae79a55951e94df3610@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --subject='Re: [PATCH] mm: mmap: Fix general protection fault in unlink_file_vma()' \
    /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

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).