From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792775046; b=R0y0oVZV6HTcr9y4Owi9SdszHIqxQvRzyYixDlVPYDXAO9hWmdRjR7KXas7wKneQmHTU DkLT9UQWfmPC/Rwyzmu9s3qCvFSJqo0ru1MgePTsSfSdRI51ZO4H/ab5BLuh8zQ21JRaS 1hZIPWRuA6srvHwO+4GOf9ViPbDUu6ZBLhravGgjvzXpuuRomjGp1Pft2hV+30wYpq5V/ qKji0SjMrVK5DCcfNeY1fIYxEMzaSCKRceFWdeSRYNDlOAEMZOo27V2sKtkt62yYm9Ptw hFTNi10sbXsKJhMg62eAjwiNvUo7R6Ykwe5CYyIyU+PdKQLEVRJp0NFjY3XB1KYKHrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792775046; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=V9ZJNsoTniIP1KFZN3fHNGYAr1guddKxWKcQjmLsc4Q=; b=W90eXEe2M02cdBmfNPFUWR7QFfItPfZ48Ixv1vBQi15GXzSkJqcetmb1nVEgqyBUPK36 HwuDcJm3BfP2hhp+ueWGUhgGzbnruyl1BL0Cb0CahfkqfjRl+27jaCP51E5KfR3TVFwpZ FF2sW+iHsVCXMUbroBH5BjarwO2Lp+7ZhB/ISGHMNy9X3P9IHRJ3yN/bAjc4piI7LwOwA JbwOWUNPTXQROS1Eu5Zch3MUudT1dJsTjibAEnf9eKb6n5hF1xSyUzUHf8t0LySOdtDK8 1zRQzddjyBMjNwOUl0auMqKXJBhpJtchdlNY1Ni8Mc/HUCKSdnxlFNiTo7RjhzPkhYg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=PnKzoRUQ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 806AA606A31D; Fri, 23 Oct 2026 17:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=PnKzoRUQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id D37C11F01828; Fri, 23 Oct 2026 17:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792775046; bh=V9ZJNsoTniIP1KFZN3fHNGYAr1guddKxWKcQjmLsc4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PnKzoRUQRSBvsSusHV7mBujDUx2/6GmXqZZ16YqfvHrNOoqfwOLgzwfhBlXRyYXgz nZmlJI+4PIE89a6Pps7XtBMQgbFYyGAxPtBOz0JyEK3kxbALS4ioihrwrTsiG0lz5V P9k5ZYTiBplTdZIz22XJv90SI+BQYzfSMANFmbZY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Frank Sorenson , David Howells , Namjae Jeon , Paulo Alcantara , Christian Brauner , Matthew Wilcox , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM Subject: [PATCH 7.2 242/242] smb: client: drain outstanding I/O before truncating on O_TRUNC open Date: Fri, 23 Oct 2026 18:41:24 +0200 Message-ID: <20261023163719.587596007@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261023163713.816071858@linuxfoundation.org> References: <20261023163713.816071858@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 3581f843defa0bb30fd7da1e7dba170465e13a95 upstream. cifs_do_truncate() flushes the pagecache with filemap_write_and_wait() before resetting the file size to zero, but that does not wait for direct/async I/O that was already in flight, which can complete after the truncate and reinstate stale data past the new EOF. Drain outstanding netfs I/O with netfs_wait_for_outstanding_io() before resizing the file. Reported-by: Frank Sorenson Fixes: a8603b52b39f ("smb: client: fix data corruption with concurrent writes and O_TRUNC") 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/file.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -1012,6 +1012,8 @@ static int cifs_do_truncate(const unsign } mapping_set_error(inode->i_mapping, rc); + netfs_wait_for_outstanding_io(inode); + cfile = find_writable_file(cinode, FIND_FSUID_ONLY); rc = cifs_file_flush(xid, inode, cfile); if (!rc) {