From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795922551; b=pAkc4Lq1F9xso1ZE344WEhWlEClPpbPNFB1XhXNj8zKgtdlElJDhJ1wX7C6rQPBcO/2n 9D2T2qZed4ehn5woR85dTtCaJTH0anJ6hvsDuy7bNiOVTezaKaiIFeesn3IAaB37zYHhf wirRgXmCj0h5LXwk1/hqsKc13p71groYJOZKwS2kiuAAsn3YvXOtX9Rei/Lr8C2pbRDDE l+B0kYwLY2/6RlqK9abG2oz48TI0IlnxR6y64/9XyHpNJn5PiHxvWA0kyd8eMycyirbi3 Mm/ZmfPy9rMrD1it7apSNp/6zkGjPk1g39ITmLwB5D2PUdfCX1RfGoRl5CKUBV5Miyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795922551; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=Btpfcykar2WCOVWgiV8gfohpPRFyoMwYYqYCXh466dI=; b=lDzKdKEPE38d3r/2WiBCh38omdOt2IAcxOsSv55ZC0ih2tdacVgZQYbpaaWrvA63tFzl 70WDETVrFCw8xmgh5/aAGmctYoq0g1jh5X/AxNnqUvzqdERr+lQrnxmPglzoRznCk4q0l 1Tx7lEcSC8w/Ls2GveLGUH6niddFbMoUrBmP8I3/kJswiKP/o2GdIzS6Ucu861MO9zoAc Qzvo48v/SdNpMSN51KQ5TbgfEWb7HxhnDkDD6Jswtykqp6zq4IZY76fiako3F0hbbKmur BVvM2gzBS9/qEXGoK6tmJewVa+gZb3rbNb6pIAer9cBFVN89gM5bLMxFrY5TlnfUd7A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=XBFufDGE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC41A606A31C; Sun, 29 Nov 2026 03:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=XBFufDGE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C5BE1F000C1; Sun, 29 Nov 2026 03:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1795922551; bh=Btpfcykar2WCOVWgiV8gfohpPRFyoMwYYqYCXh466dI=; h=Date:To:From:In-Reply-To:References:Subject; b=XBFufDGEZ5i8OIpiks9C7en8anNGqTlqruT7GvCkuC9d0ROFJuT2s7jfQIkRXdSeL F8YsMkRQ+hFHJYyHjg/c3fKbURkrr8y5mJZbE7DFgDOSkQ2qqFwNK5nrtvf68bfLEJ GJb7i09Ny9rgCul5xe6MWxC13eA+74vbxAFye4Bk= Date: Sat, 28 Nov 2026 19:22:30 -0800 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 From: Andrew Morton In-Reply-To: <20261127072340.73758-1-zhaogongyi@bytedance.com> References: <20261127072340.73758-1-zhaogongyi@bytedance.com> Subject: + mm-readahead-read-folio-order-limits-under-the-invalidate-lock.patch added to mm-new branch Message-Id: <20261129032231.1C5BE1F000C1@smtp.kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 Signed-off-by: Andrew Morton Reviewed-by: Jan Kara Cc: Matthew Wilcox (Oracle) Cc: Jens Axboe Cc: Jinchao Wang Cc: # 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