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 E5E634E73CC; Fri, 9 Oct 2026 14:50:45 +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=1791557446; cv=none; b=dUw3hdg4Fg6oWKFuDhHLyD47Ydw/MD++ZNegy9yYIUQBbkO1S1Iju48mxEIPks7Iq8hX/1EFIWaMEA7ClPugo/3kNyfGm+YNDV0SbazonRZJDIv/gXE5QQHzs4qzWMz1zQ8qrULaf2ZnnHK4r/XV5wlMM5cjvAdQc7w+QbZLatM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791557446; c=relaxed/simple; bh=GklUTorcQmVvqB8/GCE5DzarEAZmNInC/OPwHDs0LsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a8jDjrNrc1OJblvEsH51A8xcwcCDQpK9rlXD44H7QnlYQcPqBhvZkeUYqqy3hsCYkLv2Oy3HsjNPrirqw9o25xHTwLc4VNkpQyySdYyLP3CyzdrQ6FwYeby6mAkAgfrDqITh+NLCHk87VNL9s8T3N4E2E4z8vMKd9FpJBy7R6YU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LlKXfDWU; 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="LlKXfDWU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 513731F000FF; Fri, 9 Oct 2026 14:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791557445; bh=Oj1xRSDlAxtx79NBVOa1pi6J7UhLBH9QcgX4W4MxTtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LlKXfDWUX0gilqyHZvuohm6j+NkewBuZolnqFTPohYJ7ePPAL/fs0r/2yxTRAuiKW ASys8bf+u+OXkelgbL7RYPbwmOuE4L50JcZpiqo29yiawrliAjL0edlNtnZPaaHaVn 0EoOEXR04iZm3IQQ9cZSWrRtZVUurjIDgoTdoMno= 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 7.2 362/428] smb: client: discard post-EOF pagecache when extending a file via clone range Date: Fri, 9 Oct 2026 16:11:39 +0200 Message-ID: <20261009140954.128440889@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140946.008206689@linuxfoundation.org> References: <20261009140946.008206689@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara commit 4721587f96cb8de8164f3fd203093a0875560999 upstream. cifs_remap_file_range() discarded the pagecache only for the folios overlapping the destination region, so when a clone 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 discard at the smaller of fstart and the old EOF. i_size is still old here, so nothing past the old EOF is flushed to the server. Fixes: c54fc3a4f375 ("cifs: Fix flushing, invalidation and file size with FICLONE") 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1467,9 +1467,14 @@ static loff_t cifs_remap_file_range(stru i_size = target_inode->i_size; spin_unlock(&target_inode->i_lock); - /* Discard all the folios that overlap the destination region. */ + /* + * Discard all the folios that overlap the destination region. 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. + */ cifs_dbg(FYI, "about to discard pages %llx-%llx\n", fstart, fend); - truncate_inode_pages_range(&target_inode->i_data, fstart, fend); + truncate_inode_pages_range(&target_inode->i_data, + min(fstart, i_size), fend); fscache_invalidate(cifs_inode_cookie(target_inode), NULL, i_size, 0);