summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc
diff options
context:
space:
mode:
authorkoraynilay <koray.fra@gmail.com>2026-11-12 12:16:36 +0100
committerNamjae Jeon <linkinjeon@kernel.org>2026-11-15 10:08:13 +0900
commitf2f961e0983c8f339f842e1a8c351e6963793868 (patch)
tree62cfc096c9927f0e035f9574b603d3da87d769ed /tools/lib/python/kdoc
parentfecd3599f21255553989b4a4303de77ec05ac556 (diff)
ksmbd: fix negative timestamps being saved to disk
When setting a timestamp before epoch 0, ksmbd converts it from NT format to Unix format without normalizing it, leading to the nanoseconds field to be saved (on-disk too) as a negative number, which leads to a garbled stat command output and a reported +4 seconds in the timestamp. This bug also violates a struct timespec64 invariant, as documented in the set_normalized_timespec64() kernel-doc: [...] * Note: The tv_nsec part is always in the range of 0 <= tv_nsec < NSEC_PER_SEC. * For negative values only the tv_sec field is negative ! */ Reproducer, 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=user,password=pass touch /mnt/test.txt touch -d "1969-07-20 20:17:40.123456789" /mnt/test.txt stat -c "Server local (/tmp): %y" /tmp/test.txt stat -c "CIFS client (/mnt): %y" /mnt/test.txt --cached=never smbclient //127.0.0.1/test -U user%pass -c "allinfo test.txt" which prints (stat output is garbled because of negative value): Server local (/tmp): 1969-07-20 20:17:41.()*+,--00 +0000 CIFS client (/mnt): 1969-07-20 20:17:45.+(/+)*/00 +0000 altname: TESTT~K6.TXT [...] access_time: Sun Jul 20 20:17:44 1969 UTC write_time: Sun Jul 20 20:17:44 1969 UTC [...] Fix this by using set_normalized_timespec64() in ksmbd_NTtimeToUnix(). Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Cc: stable@vger.kernel.org Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.3 Signed-off-by: koraynilay <koray.fra@gmail.com> Reviewed-by: Ian Bridges <icb@fastmail.org> Tested-by: Ian Bridges <icb@fastmail.org> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc')
0 files changed, 0 insertions, 0 deletions