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 B6C7E342173; Fri, 9 Oct 2026 14:50:37 +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=1791557438; cv=none; b=ZF6T5IQmHxkqovFY4yH2NM6Wo/cG/Fj/Ny5awuu8UnNismcgzxxosTStGRkiGbrC7d76I+e2MPgQWeikmPKjbZfHBTEKIt4bmcZT6UObfVudgU8IyinOnZIPUY8rDX6OrEmRLEdN7ETwwDbFDeP8ioySl9sIdiQ2eZc2/wppmzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791557438; c=relaxed/simple; bh=6jB6Lu4lrox5la3+HSNulMIOgwCxS4x2W+87PEiK3q8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JHrpkiA+DIJ3szWTZ8AmBqhHxLqH67XnbQND/hsc9kuExJHOrk+sQIVL7r9AjCPC7RboCN+55gHNjtfx/tr7e/oYwrOy/n3c87OzaY2ghmVs/yfjMf9RHBjSFEK2tPpDYIZyOiShifYgel6dkBB9x33e89r6HUvDIJgT8KlDA6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vQr2dZna; 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="vQr2dZna" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3D031F000FF; Fri, 9 Oct 2026 14:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791557437; bh=yKshlCW6xyu12VUMOhuUt9rRpmpUcH/N60NSQmcQOT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vQr2dZna52kYCHCLf0OdimMVDmgNaDHsacum/2yXg+rQCv087Z1t7RQn86EIufas5 a/QdhXNwppyBabXdR1XgOSDbUlQ44Tj+STaWVqtQSIrfGrgO2KPNNnywcal+rlMi2A G/VYaxcYLcbHvmV7UGPoGYY7MFWdiXuRmZNywbWQ= 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 360/428] smb: client: discard post-EOF pagecache when extending a file via zero range Date: Fri, 9 Oct 2026 16:11:37 +0200 Message-ID: <20261009140954.080539962@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 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 @@ -3555,8 +3555,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 */