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=1796382787; b=txetdlOu2NQP9/w3oBCD7mmqhZS4RuExiO8c9DzjNjhHnO5CbYv9ufBRdnYgStY9wWa4 KYG9B1AIRJemZNi/v9Wxiu1aAXLS/p3i1dJxBOuS5HNNoJG9fYUsea4WzIrnq/ZFadcL7 V2eobQB5S2IzBehcjXfs9uKEzTkwPE57+oFOjtrGNuq6gqVcq/RZEU9O2+k96pYMywPav 4+vj3YQL/j2kXpTleFvFvdM4aJV/HS64aAp2QVE0pYdjM6XORSACodQCWf5K3OTZl27Ss 8KUF3nzpppt8biKqZjNb+mnm4kxqWG8RFXgkQy0RkttXZ7O15mzf+LrQfQp/Miwyu7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382787; 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=zJngz7NiaxmOVaWlrJcXpSsF2llm2UC4ZpyFAPO/uWc=; b=dy75x1wRkWL17g92Vvbeb8rnqRvdQcy22fNW6q2IweDMvT3Boj55rhluEAo7KVP9p/u/ cmo3TGqYDQEeMFjUOy8GCsq6qwFjIIe7mwMgXa+i4r32s+wCclCEzPXcshi6CWlcfWILh DT0sma29e6nkSAUk5e5mo2ODiSYHTw0BOrNTbUrI7OKguEVzhnWGwJu5eL3No9zutXOOk tKShhSR1z2fpAk7XGIGUQ+Zn2AEWXZQr/bOsY5NFs7CQSmlWNXQ3W39UZriTKRyBvmg3h qt6ZHk9Q/bXLuYF5Ds6ZjoJiHX1lpxurBIPRWKg9ORVMcySztnK2xzZIbeF/cO5e5gg== 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=cOfDETDJ; 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 0AC50606A322; Fri, 4 Dec 2026 11:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=cOfDETDJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DD721F000CE; Fri, 4 Dec 2026 11:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382786; bh=zJngz7NiaxmOVaWlrJcXpSsF2llm2UC4ZpyFAPO/uWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cOfDETDJIgqv7IHWb6fbPfTI3xEG07G+c2RnP7p2mdqox5m64/tcW2ChEkj0yfMMw dCq1xKiKVly9Z1fupYtIkruEUZksONHqsZCTeUNrbWwHIInNdKuXUNmHVQTarVbfaR Y+ymVzVhKWQdTRroh+BCSXAsadPGubEI3zYbss2Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , koraynilay , Namjae Jeon , Paulo Alcantara Subject: [PATCH 6.18 583/703] smb: client: fix times assignments in cifs_posix_to_fattr() Date: Fri, 4 Dec 2026 19:08:02 +0900 Message-ID: <20261204100643.265737305@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: koraynilay commit 8b456f136a76a29fee8d36934740cb7f7fb5c837 upstream. Currently cifs_posix_to_fattr() wrongly sets SMB's CreationTime to fattr->cf_ctime. Fix this by setting fattr->cf_createtime to SMB's CreationTime and fattr->cf_ctime to SMB's ChangeTime, matching the behaviour of __dir_info_to_fattr(). This patch also fixes a few related issues reported by sashiko on another patch (see Sashiko Link tag). Reproducers for these bugs, with /tmp as the local filesystem folder exported as [test] in ksmbd.conf and /mnt as the smb folder mounted with mount -t cifs: mount -t cifs //127.0.0.1/test /mnt -o username=ciao,password=c,posix Issue 1: ctime clobbered by CreationTime during readdir mkdir -p /mnt/dir touch /mnt/dir/file sleep 4 chmod 644 /mnt/dir/file stat -c "ctime and btime before readdir: %Z %W" /mnt/dir/file ls -lc /mnt/dir > /dev/null stat -c "ctime and btime after readdir: %Z %W" /mnt/dir/file stat -c "ctime and btime on disk: %Z %W" /tmp/dir/file output before the fix, notice how ctime is the same as btime after the readdir, while it's 4 seconds ahead (because of the sleep 4) before the readdir (on disk timestamps are not touched): ctime and btime before readdir: 1794842068 1794842064 ctime and btime after readdir: 1794842064 1794842064 ctime and btime on disk: 1794842068 1794842064 output after the fix: ctime and btime before readdir: 1794842908 1794842904 ctime and btime after readdir: 1794842908 1794842904 ctime and btime on disk: 1794842908 1794842904 Issue 2: btime and ptime wiped out by readdir [ no reproducer as it only happens after the linked patch series is applied, since it needs cifs_i->createtime = fattr->cf_createtime in cifs_fattr_to_inode() ] Issue 3: in-memory inode aliasing (flock bypass on hardlink via readdir) mkdir -p /mnt/dir1 /mnt/dir2 echo "test" > /mnt/dir1/h1 ln /mnt/dir1/h1 /mnt/dir2/h2 exec 3< /mnt/dir1/h1 flock -x -n 3 # get exclusive lock ls /mnt/dir2 > /dev/null exec 4< /mnt/dir2/h2 flock -x -n 4 if [ $? -eq 0 ];then echo "acquired: duplicate in-memory inode" else echo "blocked: same inode" fi output before the fix: acquired: duplicate in-memory inode output after the fix: blocked: same inode Fixes: 3d519bd1269f ("cifs: plumb smb2 POSIX dir enumeration") Cc: stable@vger.kernel.org Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20261115180343.576773-1-koray.fra%40gmail.com?part=10 Link: https://lore.kernel.org/all/20261115180343.576773-11-koray.fra@gmail.com/ Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.7 Signed-off-by: koraynilay Reviewed-by: Namjae Jeon Signed-off-by: Paulo Alcantara Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/readdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/smb/client/readdir.c +++ b/fs/smb/client/readdir.c @@ -253,9 +253,10 @@ cifs_posix_to_fattr(struct cifs_fattr *f fattr->cf_bytes = le64_to_cpu(info->AllocationSize); fattr->cf_eof = le64_to_cpu(info->EndOfFile); + fattr->cf_createtime = le64_to_cpu(info->CreationTime); fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); - fattr->cf_ctime = cifs_NTtimeToUnix(info->CreationTime); + fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime); fattr->cf_nlink = le32_to_cpu(info->HardLinks); fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes);