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 AA32F3D891D; Tue, 13 Oct 2026 12:42:59 +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=1791895380; cv=none; b=hgpIUKEF6A7xSbAGgTKqema2wiA5ETiqjsxz8nfa1bkXUj2buf842o1YRKnARWT2u+amvVvVlrMAVbCQ8LaMrRY8v9QybRFIX7Nd7rumeqeE3mZdshisC6FljSIE2V35PZfyrF4Tz0H/ePKnPSJgRX/Y5x4jcgqAjtItfOSzVKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791895380; c=relaxed/simple; bh=eLTY7TT1SLO8hVvmabHFjoNr7XNVIMrtdQyTGZOHmCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bXPOOR5+QjVSP9ZWpyUd80V7fuolO0d+npiEbn8inoUJ0193W9aATEFH8no52mfqkawrvX0Mhpqz7mBEsoxBg90kMzN+9DQs3Cde0h0aQ0yvPR1Sdm7tImeWjek1x/LkqVPTt/MxbsIuhbxgO1Rh3N2gBsWEbd3EyWtfvAkKC50= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AqrHupLj; 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="AqrHupLj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 079961F000FF; Tue, 13 Oct 2026 12:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791895379; bh=WcA+fsFe45P8vqUYQHEQAqRiJL8g0kpb5Rc9dvTXry4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AqrHupLjSnITorQnlY0YvqbRDidrtJB1yckoEMlx2ogrqsxbhzo2s6zVJjgWzev8x gYLpskweFPy8MnLWllKEVLneZynzivNJUFdqg52RAu9NLEBnfdkPaHCuPRqMPFjRYX MMHN22uTGo9PQ3rYVlJJLLARbLJ9Zqon24bEP0vU= 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.12 228/497] smb: client: discard post-EOF pagecache when extending a file via zero range Date: Tue, 13 Oct 2026 13:36:35 +0200 Message-ID: <20261013112913.305686038@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112907.864180619@linuxfoundation.org> References: <20261013112907.864180619@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara commit da4fe97fb6c730d9c94a115c7bfa6f98e0d578d0 upstream. smb3_zero_range() removed the pagecache only for the range being zeroed, so when it 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. Lower the discard boundary to the smaller of the zero-range offset and the old EOF. Fixes: 72c419d9b073 ("cifs: fix smb3_zero_range so it can expand the file-size when required") 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/smb2ops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3521,8 +3521,11 @@ static long smb3_zero_range(struct file /* * We zero the range through ioctl, so we need remove the page caches * first, otherwise the data may be inconsistent with the server. + * + * 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. */ - truncate_pagecache_range(inode, offset, offset + len - 1); + truncate_pagecache_range(inode, min(offset, i_size), offset + len - 1); netfs_wait_for_outstanding_io(inode); /* if file not oplocked can't be sure whether asking to extend size */