linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: syzbot <syzbot+6e4f59235036c3c2e296@syzkaller.appspotmail.com>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [mm?] WARNING in page_add_anon_rmap
Date: Mon, 18 Sep 2023 14:53:22 +0200	[thread overview]
Message-ID: <1fe06726-85bf-7231-f33d-d73e8cfbaa4f@redhat.com> (raw)
In-Reply-To: <ZQhDRtWYSJWfHvEM@casper.infradead.org>

On 18.09.23 14:32, Matthew Wilcox wrote:
> On Mon, Sep 18, 2023 at 12:00:24PM +0200, David Hildenbrand wrote:
>>> If you want syzbot to run the reproducer, reply with:
>>> #syz test: git://repo/address.git branch-or-commit-hash
>>> If you attach or paste a git patch, syzbot will apply it before testing.
> 
> If I understand correctly, you have to do it like this:
> 
> #syz test
> 
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 789a2beb8b3a..f13a2927163d 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1249,8 +1249,10 @@ void page_add_anon_rmap(struct page *page, struct vm_area_struct *vma,
>   	}
>   	if (flags & RMAP_EXCLUSIVE)
>   		SetPageAnonExclusive(page);
> -	VM_WARN_ON_FOLIO(page_mapcount(page) > 1 && PageAnonExclusive(page),
> -			 folio);
> +	/* While PTE-mapping a THP we have a PMD and a PTE mapping. */
> +	VM_WARN_ON_FOLIO((atomic_read(&page->_mapcount) > 0 ||
> +			  (folio_test_large(folio) && folio_entire_mapcount(folio) > 1)) &&
> +			 PageAnonExclusive(page), folio);
>   	mlock_vma_folio(folio, vma, compound);
>   }

Looks like an empty line went missing in your attempt.

Let's try again for fun (I reproduced and tested myself already ;) ).


#syz test

diff --git a/mm/rmap.c b/mm/rmap.c
index 789a2beb8b3a..f13a2927163d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1249,8 +1249,10 @@ void page_add_anon_rmap(struct page *page, struct vm_area_struct *vma,
  	}
  	if (flags & RMAP_EXCLUSIVE)
  		SetPageAnonExclusive(page);
-	VM_WARN_ON_FOLIO(page_mapcount(page) > 1 && PageAnonExclusive(page),
-			 folio);
+	/* While PTE-mapping a THP we have a PMD and a PTE mapping. */
+	VM_WARN_ON_FOLIO((atomic_read(&page->_mapcount) > 0 ||
+			  (folio_test_large(folio) && folio_entire_mapcount(folio) > 1)) &&
+			 PageAnonExclusive(page), folio);
  
  	mlock_vma_folio(folio, vma, compound);
  }
-- 
2.41.0

-- 
Cheers,

David / dhildenb



  parent reply	other threads:[~2023-09-18 12:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18  3:57 syzbot
2023-09-18  7:41 ` David Hildenbrand
2023-09-18 10:00 ` David Hildenbrand
2023-09-18 12:32   ` Matthew Wilcox
2023-09-18 12:36     ` syzbot
2023-09-18 12:53     ` David Hildenbrand [this message]
2023-09-18 13:14       ` 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=1fe06726-85bf-7231-f33d-d73e8cfbaa4f@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=syzbot+6e4f59235036c3c2e296@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=willy@infradead.org \
    /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