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 09D333D34A2; Fri, 9 Oct 2026 14:39:55 +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=1791556797; cv=none; b=jxBAasvS896v9C5hi8Cg15dAnGv5URCWrp2iIVw8q/TCan4sQjQviyvQzzR954mlis9b5GvtT4mhnnUVfbbvSmTje04qToHhSLSdG9OylbyiGPnppFEngqQyk1dndrreNgSHfk3cntYtkhirDoU7TbmGtDJVP8NILhZYvPZIo2w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791556797; c=relaxed/simple; bh=okFwKWcx0zvupxg2G2FVSCbUuwQSd8ARIqW3pMOH4PA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hDam6zhh+i1RvHdNvTNBav6Bnqyx6C1N4qOD2ew4RNdGQCh9unFXYOvTUs/8SitSz9i6IfnKrd3diD9gHKz85gC6khzWJYJiLPPCh3yYSLO7dkG1INXZ1QXj5QCh3GASEyZOvA0NtmH0H6Ij8WOVCj4/JDMbZyoUiS4d7T5Wbm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hWm+DQJH; 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="hWm+DQJH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 294E31F000FF; Fri, 9 Oct 2026 14:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791556795; bh=bwWlN1oHweVigMJVkVlQpKqKCO9TwMpmPuAzARy2Wuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hWm+DQJH4OwvcUve95KMhzQpIRN1xOMBQ3k41oU+ekb5qnZtUNyPza/U3h3zjdQg6 5Bw0Qvdz4OKOGLe/U92uVp32b6wVj3zeCEdX6jHzi/3yUBsIIU4VMLn9bw8wbmpYbr k3hFNhvjIR7/UAEWRt3PUUdRXV5GeNTr4zxniFro= 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 294/403] smb: client: discard post-EOF pagecache when extending a file via zero range Date: Fri, 9 Oct 2026 16:10:55 +0200 Message-ID: <20261009140959.080223079@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 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 @@ -3517,8 +3517,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 */