Linux Sound subsystem development
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	syzbot <syzbot+263f159eb37a1c4c67a4@syzkaller.appspotmail.com>,
	akpm@linux-foundation.org, chaitanyas.prakash@arm.com,
	davem@davemloft.net, edumazet@google.com, hdanton@sina.com,
	horms@kernel.org, kuba@kernel.org, kuniyu@google.com,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	netdev@vger.kernel.org, pabeni@redhat.com, perex@perex.cz,
	syzkaller-bugs@googlegroups.com, tiwai@suse.com,
	willemb@google.com
Subject: Re: [syzbot] [sound?] kernel BUG in filemap_fault (2)
Date: Wed, 17 Sep 2025 11:04:12 +0200	[thread overview]
Message-ID: <4551b48c-eba5-42a3-aa53-74d412a126b9@redhat.com> (raw)
In-Reply-To: <s5pl5yhhxyz7dn4r2v6c4ll53ejboe5xa5226ytgg7kjirgmh5@tofyas4lp4uy>

>>
>> 	if (!lock_folio_maybe_drop_mmap(vmf, folio, &fpin))
>> 		goto out_retry;
>>
>> 	/* Did it get truncated? */
>> 	if (unlikely(folio->mapping != mapping)) {
>> 		folio_unlock(folio);
>> 		folio_put(folio);
>> 		goto retry_find;
>> 	}
>> 	VM_BUG_ON_FOLIO(!folio_contains(folio, index), folio);
>>
>>
>> I would assume that if !folio_contains(folio, index), either the folio got
>> split in the meantime (filemap_get_folio() returned with a raised reference,
>> though) or that file pagecache contained something wrong.
> 
> Right.
> 
>> In __filemap_get_folio() we perform the same checks after locking the folio
>> (with FGP_LOCK), and weird enough it didn't trigger yet there.
> 
> But we don't call __filemap_get_folio() with FGP_LOCK from filemap_fault().

Yes. I should have clarified that we haven't seen the VM_BUG_ON_FOLIO() 
trigger on other callpaths that set FGP_LOCK, because I would think the 
very same problem could happen there as well.

> The folio locking is handled by lock_folio_maybe_drop_mmap() as you
> mentioned. So this is the first time we do the assert after getting the
> folio AFAICT. So some race with folio split looks plausible. Checking the
> reproducer it does play with mmap(2) and madvise(MADV_REMOVE) over the
> mapped range so the page fault may be racing with
> truncate_inode_partial_folio()->try_folio_split(). But I don't see the race
> there now...

__filemap_get_folio() will grab a reference and verify that the xarray 
didn't change. So having a concurrent split succeed would be weird, 
because freezing the refcount should fail. Of course, some refcounting 
inconsistency could trigger something weird like that.

I can spot that we are also manually calling 
__filemap_get_folio(FGP_CREAT|FGP_FOR_MMAP) on the else path if 
filemap_get_folio() failed, maybe that's the problematic bit (and maybe 
that's where readahead logic makes a difference).

-- 
Cheers

David / dhildenb


      reply	other threads:[~2025-09-17  9:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 11:13 [syzbot] [sound?] kernel BUG in filemap_fault (2) syzbot
2025-07-03 16:43 ` [syzbot] [net?] " syzbot
2025-09-14 10:51 ` [syzbot] [sound?] " syzbot
2025-09-16 12:50   ` Ryan Roberts
2025-09-16 13:05     ` Jan Kara
2025-09-17  7:57       ` David Hildenbrand
2025-09-17  8:35         ` Jan Kara
2025-09-17  9:04           ` David Hildenbrand [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=4551b48c-eba5-42a3-aa53-74d412a126b9@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chaitanyas.prakash@arm.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hdanton@sina.com \
    --cc=horms@kernel.org \
    --cc=jack@suse.cz \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=perex@perex.cz \
    --cc=ryan.roberts@arm.com \
    --cc=syzbot+263f159eb37a1c4c67a4@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tiwai@suse.com \
    --cc=willemb@google.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