Skip to contentSkip to conversation

ksmbd: set create_time to btime in ksmbd_vfs_fill_dentry_attrs()

PATCH Applied koraynilay 3 participants 4 messages Nov 10

Subsystems (2)
lore
Share & tools
lore

koraynilay

author
#0 lore raw

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().

Fixes 5614c8c487f6 ("ksmbd: replace generic_fillattr with vfs_getattr")
Assisted-by Gemini:3.8-flash-high antigravity-cli-1.5.3

---
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
index cb3f4f5fe9cf..0c95d4668370 100644
@@ -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
Reviewed-by Tested-by on v1 1/1
#1 lore raw

Hi,

Quoted 3 lines · koraynilay

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.

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.

maintainer Applied
#2 lore raw
Quoted 16 lines · Ian Bridges

Hi,

Quoted 3 lines · koraynilay

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.

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 2 lines

Applied this patch to #ksmbd-for-next.
Thanks!

author
#3 lore raw
Quoted 17 lines · Namjae Jeon
Quoted 16 lines · Ian Bridges

Hi,

Quoted 3 lines · koraynilay

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.

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 4 lines
Quoted 2 lines

Applied this patch to #ksmbd-for-next.
Thanks!

Thanks!

Best,
koraynilay