ksmbd: set create_time to btime in ksmbd_vfs_fill_dentry_attrs()
Subsystems (2)
PATCH 1/1 ksmbd: set create_time to btime in ksmbd_vfs_fill_dentry_attrs()
ksmbd_vfs_fill_dentry_attrs() queries vfs_getattr() with STATX_BTIME, but discards ksmbd_kstat->kstat->btime and unconditionally initializes ksmbd_kstat->create_time to ksmbd_kstat->kstat->ctime.
Check ksmbd_kstat->kstat->result_mask for STATX_BTIME and set ksmbd_kstat->create_time to ksmbd_kstat->kstat->btime, only falling back to ctime if btime isn't returned, matching the existing behavior in smb2_open().
---
Small fix I found while implementing ptime[1].
Thanks.
[1]: https://lore.kernel.org/all/[email protected]/T/#t
fs/smb/server/vfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/server/vfs.c +4 -1
@@ -1914,7 +1914,10 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,if (rc)return rc; - time =ksmbd_UnixTimeToNT (ksmbd_kstat->kstat->ctime); +if (ksmbd_kstat->kstat->result_mask &STATX_BTIME ) + time =ksmbd_UnixTimeToNT (ksmbd_kstat->kstat->btime); +else + time =ksmbd_UnixTimeToNT (ksmbd_kstat->kstat->ctime); ksmbd_kstat->create_time = time;/*
base-commit: b0af9a3e6b1534d353ca6ac23caaf46127f62e4a
Signature · 1 line
2.56.0
Hi,
Quoted 3 lines · koraynilay
ksmbd_vfs_fill_dentry_attrs()queriesvfs_getattr()withSTATX_BTIME, but discardsksmbd_kstat->kstat->btimeand unconditionally initializesksmbd_kstat->create_timetoksmbd_kstat->kstat->ctime.
I tested this on a kernel whose fs/smb/server matches ksmbd-for-next, with files and a directory created on the server, so without the DOS attribute xattr. Before the patch, a directory listing reported their ctime as the creation time, while a query on the open file reported the btime. With the patch, both report the btime. A file created over SMB keeps its stored creation time in both. smbtorture gives the same results as without the patch, and KASAN reports nothing.
Quoted 16 lines · Ian Bridges
Hi,
Quoted 3 lines · koraynilay
ksmbd_vfs_fill_dentry_attrs()queriesvfs_getattr()withSTATX_BTIME, but discardsksmbd_kstat->kstat->btimeand unconditionally initializesksmbd_kstat->create_timetoksmbd_kstat->kstat->ctime.I tested this on a kernel whose
fs/smb/servermatches ksmbd-for-next, with files and a directory created on the server, so without the DOS attribute xattr. Before the patch, a directory listing reported their ctime as the creation time, while a query on the open file reported the btime. With the patch, both report the btime. A file created over SMB keeps its stored creation time in both. smbtorture gives the same results as without the patch, and KASAN reports nothing.
Quoted 2 lines
Reviewed-by Ian Bridges <[email protected]>Tested-by Ian Bridges <[email protected]>
Applied this patch to #ksmbd-for-next.
Thanks!
Quoted 17 lines · Namjae Jeon
Quoted 16 lines · Ian Bridges
Hi,
Quoted 3 lines · koraynilay
ksmbd_vfs_fill_dentry_attrs()queriesvfs_getattr()withSTATX_BTIME, but discardsksmbd_kstat->kstat->btimeand unconditionally initializesksmbd_kstat->create_timetoksmbd_kstat->kstat->ctime.I tested this on a kernel whose
fs/smb/servermatches ksmbd-for-next, with files and a directory created on the server, so without the DOS attribute xattr. Before the patch, a directory listing reported their ctime as the creation time, while a query on the open file reported the btime. With the patch, both report the btime. A file created over SMB keeps its stored creation time in both. smbtorture gives the same results as without the patch, and KASAN reports nothing.
Quoted 4 lines
Quoted 2 lines
Reviewed-by Ian Bridges <[email protected]>Tested-by Ian Bridges <[email protected]>Applied this patch to #ksmbd-for-next.
Thanks!
Thanks!
Best,
koraynilay