From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,willy@infradead.org,wangjinchao600@gmail.com,
stable@vger.kernel.org,jack@suse.cz,axboe@kernel.dk,zhaogongyi@bytedance.com,
akpm@linux-foundation.org
Subject: + mm-readahead-read-folio-order-limits-under-the-invalidate-lock.patch added to mm-new branch
Date: Sat, 28 Nov 2026 19:22:30 -0800 [thread overview]
Message-ID: <20261129032231.1C5BE1F000C1@smtp.kernel.org> (raw)
In-Reply-To: <20261127072340.73758-1-zhaogongyi@bytedance.com>
The patch titled
Subject: mm/readahead: read folio order limits under the invalidate lock
has been added to the -mm mm-new branch. Its filename is
mm-readahead-read-folio-order-limits-under-the-invalidate-lock.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-readahead-read-folio-order-limits-under-the-invalidate-lock.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Zhao Gongyi <zhaogongyi@bytedance.com>
Subject: mm/readahead: read folio order limits under the invalidate lock
Date: Fri, 27 Nov 2026 15:23:40 +0800
Block device mmap readahead can race with set_blocksize(), which updates
the block size and minimum folio order under the exclusive invalidate
lock. page_cache_ra_order() reads the minimum before taking the shared
lock and can allocate a folio smaller than the new block size. On the
buffer-head path this can cause a NULL dereference in guard_bio_eod().
Take the existing shared invalidate lock before computing the folio order
limits so they stay valid through allocation and I/O submission.
Link: https://patch.msgid.link/20261127072340.73758-1-zhaogongyi@bytedance.com
Fixes: 47dd67532303 ("block/bdev: lift block size restrictions to 64k")
Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jinchao Wang <wangjinchao600@gmail.com>
Cc: <stable@vger.kernel.org> # 7.3+
mm/readahead.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--- a/mm/readahead.c~mm-readahead-read-folio-order-limits-under-the-invalidate-lock
+++ a/mm/readahead.c
@@ -484,7 +484,7 @@ void page_cache_ra_order(struct readahea
struct address_space *mapping = ractl->mapping;
pgoff_t start = readahead_index(ractl);
pgoff_t index = start;
- unsigned int min_order = mapping_min_folio_order(mapping);
+ unsigned int min_order;
pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT;
pgoff_t mark;
unsigned int nofs;
@@ -506,15 +506,17 @@ void page_cache_ra_order(struct readahea
mark = ULONG_MAX;
}
+ /* See comment in page_cache_ra_unbounded() */
+ nofs = memalloc_nofs_save();
+ filemap_invalidate_lock_shared(mapping);
+
+ /* Serialize with set_blocksize() updating the minimum folio order. */
+ min_order = mapping_min_folio_order(mapping);
new_order = min(mapping_max_folio_order(mapping), new_order);
new_order = min_t(unsigned int, new_order, ilog2(ra->size));
new_order = max(new_order, min_order);
-
ra->order = new_order;
- /* See comment in page_cache_ra_unbounded() */
- nofs = memalloc_nofs_save();
- filemap_invalidate_lock_shared(mapping);
/*
* If the new_order is greater than min_order and index is
* already aligned to new_order, then this will be noop as index
_
Patches currently in -mm which might be from zhaogongyi@bytedance.com are
mm-readahead-read-folio-order-limits-under-the-invalidate-lock.patch
prev parent reply other threads:[~2026-11-29 3:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 7:23 [PATCH] mm/readahead: read folio order limits under the invalidate lock Zhao Gongyi
2026-11-27 14:41 ` Jan Kara
2026-11-29 3:22 ` Andrew Morton [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=20261129032231.1C5BE1F000C1@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=jack@suse.cz \
--cc=mm-commits@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wangjinchao600@gmail.com \
--cc=willy@infradead.org \
--cc=zhaogongyi@bytedance.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