From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org,
syzbot+9f9a7f73fb079b2387a6@syzkaller.appspotmail.com,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Hillf Danton <hdanton@sina.com>
Subject: Re: [PATCH v1] mm/filemap: don't call folio_test_locked() without a reference in next_uptodate_folio()
Date: Fri, 29 Nov 2024 15:40:29 +0200 [thread overview]
Message-ID: <2r2suyel6m6ngntarnxwtobicwignmmm3lfivvp5goufzis56e@rwtncfi7nxxn> (raw)
In-Reply-To: <20241129125303.4033164-1-david@redhat.com>
On Fri, Nov 29, 2024 at 01:53:03PM +0100, David Hildenbrand wrote:
> The folio can get freed + buddy-merged + reallocated in the meantime,
> resulting in us calling folio_test_locked() possibly on a tail page.
>
> This makes const_folio_flags VM_BUG_ON_PGFLAGS() when stumbling over
> the tail page.
>
> Could this result in other issues? Doesn't look like it. False positives
> and false negatives don't really matter, because this folio would get
> skipped either way when detecting that they have been reallocated in
> the meantime.
>
> Fix it by performing the folio_test_locked() checked after grabbing a
> reference. If this ever becomes a real problem, we could add a special
> helper that racily checks if the bit is set even on tail pages ... but
> let's hope that's not required so we can just handle it cleaner:
> work on the folio after we hold a reference.
>
> Do we really need the folio_test_locked() check if we are going to
> trylock briefly after? Well, we can at least avoid a xas_reload().
>
> It's a bit unclear which exact change introduced that issue. Likely,
> ever since we made PG_locked obey to the PF_NO_TAIL policy it could have
> been triggered in some way.
>
> Reported-by: syzbot+9f9a7f73fb079b2387a6@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/lkml/674184c9.050a0220.1cc393.0001.GAE@google.com/
> Fixes: 48c935ad88f5 ("page-flags: define PG_locked behavior on compound pages")
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Cc: Hillf Danton <hdanton@sina.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Looks reasonable:
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kiryl Shutsemau / Kirill A. Shutemov
prev parent reply other threads:[~2024-11-29 13:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-29 12:53 David Hildenbrand
2024-11-29 13:40 ` Kirill A. Shutemov [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=2r2suyel6m6ngntarnxwtobicwignmmm3lfivvp5goufzis56e@rwtncfi7nxxn \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hdanton@sina.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=syzbot+9f9a7f73fb079b2387a6@syzkaller.appspotmail.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