From: Deepakkumar Karn <dkarn@redhat.com>
To: willy@infradead.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Liam.Howlett@oracle.com, Vlastimil Babka <vbabka@suse.cz>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Deepakkumar Karn <dkarn@redhat.com>
Subject: [PATCH] pagemap: Add alert to mapping_set_release_always() for mapping with no release_folio
Date: Thu, 11 Dec 2025 01:31:04 +0530 [thread overview]
Message-ID: <20251210200104.262523-1-dkarn@redhat.com> (raw)
AS_RELEASE_ALWAYS tells the memory management code to always call
->release_folio() when releasing a folio, even if it has no private
data. Setting this flag without providing release_folio callback
leads to try_to_free_buffers() being called on folios without
buffer_heads, causing a NULL pointer dereference.
Add a VM_WARN_ONCE() alert to mapping_set_release_always() to catch
this programming error early and help prevent similar bugs in other
filesystems.
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Deepakkumar Karn <dkarn@redhat.com>
---
include/linux/pagemap.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 31a848485ad9..cc352e87ac2d 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -296,6 +296,9 @@ static inline bool mapping_release_always(const struct address_space *mapping)
static inline void mapping_set_release_always(struct address_space *mapping)
{
+ /* Alert while setting the flag with no release_folio callback */
+ VM_WARN_ONCE(!mapping->a_ops->release_folio,
+ "Setting AS_RELEASE_ALWAYS with no release_folio");
set_bit(AS_RELEASE_ALWAYS, &mapping->flags);
}
--
2.52.0
next reply other threads:[~2025-12-10 20:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 20:01 Deepakkumar Karn [this message]
2025-12-10 21:36 ` [PATCH] pagemap: Add alert to mapping_set_release_always() for mapping with no release_folio Matthew Wilcox
2025-12-11 9:23 ` Jan Kara
2025-12-12 9:37 ` Deepak Karn
2025-12-12 12:18 ` Matthew Wilcox
2025-12-12 17:47 ` Jan Kara
2025-12-12 18:38 ` Deepak Karn
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=20251210200104.262523-1-dkarn@redhat.com \
--to=dkarn@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--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;
as well as URLs for NNTP newsgroup(s).