From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 444063BB112; Fri, 9 Oct 2026 14:40:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791556802; cv=none; b=Udfe/MmrWqJTraWgI7AU8C2i3gLqpcUzacpReYqJ1TeKw9HHUfmZ7EycB/dSY5iJFBop/yntH/I0Spq6Gg3/SzYCgNey+AB4AqdO7P839ttg0vQPe4PFoZIZtez5POmmf0kOadjgVWTkNbaxcHB4TfQSD80hcwlJAckRE3A5Sro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791556802; c=relaxed/simple; bh=V8iLItD4W+PxSwz/lDa1Y6yGV+T41x907K9D68Dadfc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QmT7l6R0M0/E7+qy4tGlIRCTEdSg7MiFDoQ+bIJCDkZ3QcQzJOERcAhUOF28PlcjwGbYLxPv9wMgVRLDa3r+UDBHeROUkj0XnmSHfanI0g4AZtHmeQyK+EB+F3DTmzIAaKYf2j3UIzDarNUzUFV/Xoq0o1azAh5RPW31EChQQRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YpqCek5R; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="YpqCek5R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8CF61F000FF; Fri, 9 Oct 2026 14:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791556801; bh=5sXeT7YUXRsni3Mk6zcb+MFqGUQffYN1xkEDzw1OnbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YpqCek5RKZ8EWKpqAMdhE0ChZylbqxzYEjYid+GfMgug5FYvZd5PBX2I4LUxUxqWR xrqLuzSmv7Z4wGbleMiV8ewOzQraMJAwLssc7R8Ofs3+VLqWzXuThPl33w+MNj76Rr VS7V6rXR3eHwBvxtkw8EuNwqwI5G9RsglQ/sqV2Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Howells , Namjae Jeon , Paulo Alcantara , Christian Brauner , Matthew Wilcox , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM Subject: [PATCH 6.18 295/403] smb: client: discard post-EOF pagecache when extending a file via copy range Date: Fri, 9 Oct 2026 16:10:56 +0200 Message-ID: <20261009140959.105182758@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140952.119038291@linuxfoundation.org> References: <20261009140952.119038291@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara commit 7b473ac7cd6f7e087876d3c67b1bc6df662fb429 upstream. cifs_file_copychunk_range() invalidated the pagecache only for the destination region, so when a copy extends the file the folio straddling the old EOF - which may hold data dirtied past EOF through an mmap - was never dropped and became visible as file content once the file was extended. Start the invalidation at the smaller of the destination offset and the old EOF. filemap_invalidate_inode() writes back before invalidating while i_size is still old, so nothing past the old EOF is flushed to the server. Fixes: 8101d6e112e2 ("cifs: Fix copy offload to flush destination region") Reviewed-by: David Howells Reviewed-by: Namjae Jeon Signed-off-by: Paulo Alcantara Cc: Christian Brauner Cc: Matthew Wilcox Cc: Ronnie Sahlberg Cc: Shyam Prasad N Cc: Tom Talpey Cc: Bharath SM Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/cifsfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1539,8 +1539,13 @@ ssize_t cifs_file_copychunk_range(unsign /* Flush and invalidate all the folios in the destination region. If * the copy was successful, then some of the flush is extra overhead, * but we need to allow for the copy failing in some way (eg. ENOSPC). + * + * Start at the old EOF when extending so the folio straddling it, which + * may hold data written past EOF through an mmap, is dropped too. */ - rc = filemap_invalidate_inode(target_inode, true, destoff, destoff + len - 1); + rc = filemap_invalidate_inode(target_inode, true, + min(destoff, i_size_read(target_inode)), + destoff + len - 1); if (rc) goto unlock;