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=1794590254; b=dcaOigHKNWTKtAR00IA/uixjpshZ4whSn4vDvaSWgYGp9mWVKAz+0xGLdOasHRGE4bws Aodj+PVvFHuwxfBX1EhGUSJEu64EaSrqCj7esHjCkAvFj6VanHI95wqzJzIvaAWI0CBZi TnUWOwmMcoQ/Kl7a9T7avk28lUSXBw9TXz7CkxwwBveh8fQ/Sjrg2yMhFkHhP2R6v0xmA xkEfj70y+xVZbeeZIdXda13wr8m+6XqJL/Dvkd+Z9KBArfMOMYWDtB7BEALBHsOCrqjry HYmgVb9U9O42P8u3HYfRG8xludfZeFQYH7E/c2D0fnkImcJZpG9yrP5txeneDRuTEsA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794590254; 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=Q3L2O4/zA8IqgV08QbOExHfO0p9KSQTXyO8hc+fSA0c=; b=2uzRqyZYXeI7uFbtIMNhXN57sKqz4AxgEJK2cZgfbvAYMEIe4CL60d33ZkU24OQ17fRB omqIuV6K+tvMhcIGkGGxFzMmZsXAGDAg4zbkPFKUNXsCyEAAyklUiVlCszbVkQi1qzzo7 qdXvb6aF1QOZV9Rq7zkGN1QjTm8CNQ9tVLzV0ZpSRbTZ0blsHzMMQ45niIzoBf7bSFkz9 s44ytqoD60eBj9P9LFdqnpsJVs/tDMC2F86lz2RBAqMLbs6EANBl3jfeGVh1inypfEg6C GtLrdacsboY6jbWPPZuI7BBSLbKKMH979MyboLvxOxWA4wYDdWuxsnFF1agW22y5v/Q== 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=Rr+ACTQB; 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 8273560A380C; Fri, 13 Nov 2026 17:17:34 +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=Rr+ACTQB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 350CD1F000C5; Fri, 13 Nov 2026 17:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794590254; bh=Q3L2O4/zA8IqgV08QbOExHfO0p9KSQTXyO8hc+fSA0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Rr+ACTQBuzqAtv6XE3tK1f39FxD9bOTcygWWLrHLtlm5xa5AMf6UiQtKFxpxlzXdt tz2bc1K377v/Sdl1T7O3FjYGmM5O5tlZ619pcWJoq+Tc/fnies9uU/TkMlfrt9834d GD3sdtkwVChF0qvg/vJji+azbzko0Lwn52dAo/y0= 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.18 249/686] mm/shmem: stop retrying folios that cannot be split Date: Fri, 13 Nov 2026 10:46:22 -0500 Message-ID: <20261113153829.481280433@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153820.902362109@linuxfoundation.org> References: <20261113153820.902362109@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 68a3a0734e3df..2ee25d8ade752 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1243,6 +1243,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