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=1795037566; b=o4BBgx9wyt1VxXLBbvcBx6/U/esK0AtzoNaAX977wE/+ff2vepYcAYCytLIa22TQsC/I OpLLFJnaXFG4U1uDFeCLdrA7bizPGoU+74ZWlicZ+ZnI2SgyE6+yoZA5oSNlPIGnezbEk gsa+1TAN3hVVLHls+gFiOW2TaUyLgAus96I3fzwlC3L/edN/dOqTtNXjUCZnNwBysH1d9 lfo+YjaaPV72UOgTc8mHbOAamGssTOBPLwFgGdtBZbVMUUh02Io5+8ADCBrItlHmnXOVN DFOfguAuxlMdRm82wOmExk479kYWfpbPYGlXCRmM92oo2fOTqGlRbXg8h3L8IW8NdgQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795037566; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=gLWdZEjJ/9l0sEG2KaDLhhdB3sC92fJPjRnDiv8OxIg=; b=e6kMkvz0dyk1nykzyZs1uaJOLGWIU10iRHi24L9NzIM7TmEla2lyzT5kxqsnEyL+ebQb CmO7/OaiGm7gAiPrxBPgNcRB0fMfvkUzEo962PQsrBgB4WoJNrDVmAEex0VJ287b7occM Lfu3wGs17O2qlLBsVVpJyQakgP/qwYEoizA8Yg8F6e4gVhr8Fpbemw1iqzunYhJOBAVfg GX9ayXC7Ws2MeQrbhWYaShuByqNzmHwjdLEOtIRM181dG0aYnJSGla9e3y90H6ctqdrKW TM+jwJhtKaK/mS2vYpFbM4jhiTiM1fdv/2IVK083BKKs3tOuSaeN5d/mRFfklRfdVXw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HFvW7PsW; 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 31276606A320; Wed, 18 Nov 2026 21:32:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HFvW7PsW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CE591F000C4; Wed, 18 Nov 2026 21:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795037566; bh=gLWdZEjJ/9l0sEG2KaDLhhdB3sC92fJPjRnDiv8OxIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HFvW7PsWIAzegDQyVaeGf9A/FUe9qJ0wYRHkghCeXNdQHXUq1liF2HUj3Ihnf8ofM Y/x1suk7SMbjEei+dxc98DIa2caoIPNfkb59lDPA8oq3KiuL6aXX9jYKGPOxJJaDlG q7o3biu2uOt1NEKoadzMlkaEHqMVgV/buyoQsN8U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , "Gregory Price (Meta)" , Zi Yan , Balbir Singh , "David Hildenbrand (Arm)" , Sasha Levin Subject: [PATCH 6.6 1442/3318] mm/shmem: stop retrying folios that cannot be split Date: Wed, 18 Nov 2026 15:34:24 +0100 Message-ID: <20261118150404.081539472@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason [ Upstream commit a842a1f947da8a7020e72f885ffbf2ce6a93685f ] A fault or collapse can insert a large folio crossing EOF after shmem_undo_range() has handled the boundary folios. If splitting that folio fails, truncate_inode_partial_folio() retains it when it is dirty. The final scan then repeatedly finds it because it restarts from an unchanged start. Truncation keeps the inode lock and ignores fatal signals while looping. A concurrent unlink() can then block other directory operations while holding the directory lock and waiting for the file's lock. Advance start past the retained folio, whose truncated part has already been zeroed. Do not move start backwards if the failed split has shrunk the folio. Fix generated by an LLM and sent by Chris Mason in private. Fixes: 55ac8bbe358b ("mm/shmem: fix race in shmem_undo_range w/THP") Cc: stable@vger.kernel.org Signed-off-by: Chris Mason Tested-by: Gregory Price (Meta) [ david: split fixes, simplify descriptions, adjust comments ] Reviewed-by: Zi Yan Reviewed-by: Balbir Singh Link: https://patch.msgid.link/20261029-fixes_shmem-v4-7-392fc715d8f6@kernel.org Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Sasha Levin --- mm/shmem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 448fc9932684b..2968248bf8c20 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1119,6 +1119,15 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, index = start; break; } + } else if (folio->mapping) { + /* + * Splitting failed, but the part in the + * range is already zeroed. The folio + * was not dropped, so skip it when + * restarting the scan to avoid retrying + * it forever. + */ + start = max(start, folio_next_index(folio)); } } folio_unlock(folio); -- 2.53.0