When a timestamp is being sent with "-1" or "-2" as its value because it should be ignored, as specified in MS-FSCC 2.4.7 FileBasicInformation, ksmbd would clobber it in both the xattr and on-disk value by setting it to -1. simple reproducer: echo test > file.txt smbclient //127.0.0.1/test -U user%pass -c "put file.txt repro.txt" smbclient //127.0.0.1/test -U user%pass -c "allinfo repro.txt" smbclient //127.0.0.1/test -U user%pass -c "setmode repro.txt +h" stat repro.txt # the actual file on disk behind smb smbclient //127.0.0.1/test -U user%pass -c "allinfo repro.txt" which would show, respectively: altname: REPRO~MQ.TXT create_time: Wed Nov 11 21:23:16 2026 UTC access_time: Wed Nov 11 21:23:16 2026 UTC write_time: Wed Nov 11 21:23:16 2026 UTC change_time: Wed Nov 11 21:23:16 2026 UTC attributes: A (20) File: /tmp/repro.txt [...] Access: 1601-01-01 00:00:00.000000000 +0000 Modify: 2026-11-11 21:58:10.145349236 +0000 Change: 2026-11-11 21:58:10.206350216 +0000 Birth: 2026-11-11 21:58:10.144349220 +0000 altname: REPRO~MQ.TXT create_time: Wed Dec 31 23:59:59 1969 UTC access_time: Mon Jan 1 00:00:04 1601 UTC write_time: Wed Nov 11 21:23:16 2026 UTC change_time: Wed Nov 11 21:23:16 2026 UTC attributes: HA (22) This patch also makes the smb2.timestamps.freeze-thaw test from smbtorture pass. Cc: stable@vger.kernel.org Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Link: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/16023025-8a78-492f-8b96-c873b042ac50 Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.3 Signed-off-by: koraynilay --- Another small-ish fix I found while implementing ptime[1]. (And probably won't be the last one :c) Thanks. [1]: https://lore.kernel.org/all/20261101015551.786044-1-koray.fra@gmail.com/T/#t fs/smb/server/smb2pdu.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 92843d2944e4..5b046f10e2ce 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -8867,6 +8867,7 @@ static int set_file_basic_info(struct ksmbd_file *fp, const struct mnt_idmap *idmap; __le32 attrs_mask = FILE_ATTRIBUTE_DIRECTORY_LE | FILE_ATTRIBUTE_COMPRESSED_LE; + s64 crtime, time; int rc = 0; if (!(fp->daccess & FILE_WRITE_ATTRIBUTES_LE)) @@ -8882,21 +8883,25 @@ static int set_file_basic_info(struct ksmbd_file *fp, (file_info->Attributes & FILE_ATTRIBUTE_TEMPORARY_LE)) return -EINVAL; - if (file_info->CreationTime) - fp->create_time = le64_to_cpu(file_info->CreationTime); + crtime = (s64)le64_to_cpu(file_info->CreationTime); + if (crtime > 0) + fp->create_time = crtime; - if (file_info->LastAccessTime) { + time = (s64)le64_to_cpu(file_info->LastAccessTime); + if (time > 0) { attrs.ia_atime = ksmbd_NTtimeToUnix(file_info->LastAccessTime); attrs.ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET); } - if (file_info->ChangeTime) { - fp->change_time = le64_to_cpu(file_info->ChangeTime); + time = (s64)le64_to_cpu(file_info->ChangeTime); + if (time > 0) { + fp->change_time = time; inode_set_ctime_to_ts(inode, ksmbd_NTtimeToUnix(file_info->ChangeTime)); } - if (file_info->LastWriteTime) { + time = (s64)le64_to_cpu(file_info->LastWriteTime); + if (time > 0) { attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime); attrs.ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET | ATTR_CTIME); } @@ -8915,7 +8920,7 @@ static int set_file_basic_info(struct ksmbd_file *fp, } if (test_share_config_flag(share, KSMBD_SHARE_FLAG_STORE_DOS_ATTRS) && - (file_info->CreationTime || file_info->Attributes)) { + (crtime > 0 || file_info->Attributes)) { struct xattr_dos_attrib da = {0}; da.version = 4; base-commit: ffde0bdfc69a0f01a081d9c1a213e63d5719e625 -- 2.56.0