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=1796384096; b=F8TOT0seAHoPtP6iJ5HmMeFVeQnAPFVMEHZUGcp27vf7m3hXTA/BX0UzcQusD9qhov5Z y2Fc21pGxELc5D/b1NGLz2LQnFjM++y8Zk0DPh1CxNkKqBm/VWu3RJaIpIqiqNgBZ4cys TJ3cFM3EgLkWY/AmJoY/SkTYfeJ6Lgz8A1+Aj8bG/q51O6rjooKy1Mh9dBmD0iVi5a75B n8hPQI917QJg4YF614/EGEqkf2pVZ3TQ21BHcoR+KHYv3SECxXzXM4X7tIzWeydL+SOGE Q5PaYTBuCG7SDSvb/Jotul7Un/XExZ5eA2qtawpvcXumLMsPztUv+cppxg3Ke7Ocekw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384096; 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=kWl1tVWB5rJ8qjULL8UTOSMh//E+DMUMfFTZ1U3n6xc=; b=wnBY/gFWbcVVrUglbyr0m/Q9MK+X4BHIcY26F5JpPh4RNpIqYZWhAp+fyd5ysgk5dBjZ ScYd187tEDTCkwHU/2ETbVXcsMKZHFkfCPrmSuJdk1aTQZ0eTUB4f8T+1A0xpn89Z37wd Nnsy+hel9hmqsxFwqx7mRhofFwSyyM0AwohfbDnWKng2dJo/98u1iUPu10Kk39YfN0V8T Fb+D36pNGkboHtzzjpNuOwEIVRZ63Az8xZ/hg+qWWW1+7sZ3yIDIFyGbLHJfaS+pltwup w5lEuUpU7MWvKDuheN/IPhrUZUV8PmJ2M0WbN8nGk6Kyxk/lpapRYNpahVroRGwpEiA== 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=AsU+4pNV; 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 6D792606A322; Fri, 4 Dec 2026 11:34:56 +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=AsU+4pNV Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD0691F000C2; Fri, 4 Dec 2026 11:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384096; bh=kWl1tVWB5rJ8qjULL8UTOSMh//E+DMUMfFTZ1U3n6xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AsU+4pNVubrmPcEPzuqyClOOAEYb4WMu38rh9TU3UESoBMjvPBnildfTygqpr7XaC 4NHNnvnO/DCaRHGPnJ25fpzNzakCtxmq8VknwJKdIigmV0gijq12QNk2LUDQso6q7J tWjOGbxP9tlHSLp8CzQ4B1/cYzIgmbYF9ZM7ATdM= 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.12 493/555] smb: client: fix times assignments in cifs_posix_to_fattr() Date: Fri, 4 Dec 2026 19:08:56 +0900 Message-ID: <20261204100627.815421671@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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 6.12-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 @@ -252,9 +252,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);