The Samba-Bugzilla – Attachment 17061 Details for
Bug 14928
Duplicate SMB file_ids leading to Windows client cache poisoning
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Prototype fix for master.
0001-WIP-file_id-thought-experiment.patch (text/plain), 3.35 KB, created by
Jeremy Allison
on 2021-12-17 07:23:46 UTC
(
hide
)
Description:
Prototype fix for master.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2021-12-17 07:23:46 UTC
Size:
3.35 KB
patch
obsolete
>From b9bb275c83ed4850a56035cbaadf3d89c1fa8575 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Thu, 16 Dec 2021 20:38:51 -0800 >Subject: [PATCH] WIP file_id thought experiment. > >Signed-off-by: Jeremy Allison <jra@samba.org> >--- > source3/include/proto.h | 1 + > source3/lib/system.c | 30 ++++++++++++++++++++++++++++++ > source3/smbd/open.c | 6 +++--- > 3 files changed, 34 insertions(+), 3 deletions(-) > >diff --git a/source3/include/proto.h b/source3/include/proto.h >index 6154b1ab26d..c6c5aa4c983 100644 >--- a/source3/include/proto.h >+++ b/source3/include/proto.h >@@ -175,6 +175,7 @@ void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time > void update_stat_ex_file_id(struct stat_ex *dst, uint64_t file_id); > void update_stat_ex_from_saved_stat(struct stat_ex *dst, > const struct stat_ex *src); >+void create_random_itime(struct stat_ex *dst); > int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf, > bool fake_dir_create_times); > int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf, >diff --git a/source3/lib/system.c b/source3/lib/system.c >index 671fc2760a0..237b94717a3 100644 >--- a/source3/lib/system.c >+++ b/source3/lib/system.c >@@ -310,6 +310,36 @@ void init_stat_ex_from_stat (struct stat_ex *dst, > dst->st_ex_iflags |= ST_EX_IFLAG_CALCULATED_FILE_ID; > } > >+/******************************************************************* >+ Create a random itime (imaginary) birthtime. >+********************************************************************/ >+ >+void create_random_itime(struct stat_ex *dst) >+{ >+ NTTIME tval; >+ struct timespec itime_rand; >+ >+ for(;;) { >+ tval = (NTTIME)generate_random_u64(); >+ /* Avoid sentinal values. */ >+ if (tval == NTTIME_OMIT) { >+ continue; >+ } >+ if (tval == NTTIME_FREEZE) { >+ continue; >+ } >+ if (tval == NTTIME_THAW) { >+ continue; >+ } >+ if (tval == NTTIME_MAX) { >+ continue; >+ } >+ break; >+ } >+ itime_rand = nt_time_to_full_timespec(tval); >+ update_stat_ex_itime(dst, itime_rand); >+} >+ > /******************************************************************* > A stat() wrapper. > ********************************************************************/ >diff --git a/source3/smbd/open.c b/source3/smbd/open.c >index 7f1aedbd1fb..88aee32c0f4 100644 >--- a/source3/smbd/open.c >+++ b/source3/smbd/open.c >@@ -4134,13 +4134,13 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, > * If we created a file and it's not a stream, this is the point where > * we set the itime (aka invented time) that get's stored in the DOS > * attribute xattr. The value is going to be either what the filesystem >- * provided or a copy of the creation date. >+ * provided or a random value. > * > * Either way, we turn the itime into a File-ID, unless the filesystem > * provided one (unlikely). > */ > if (info == FILE_WAS_CREATED && !is_named_stream(smb_fname)) { >- smb_fname->st.st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_ITIME; >+ create_random_itime(&smb_fname->st); > > if (lp_store_dos_attributes(SNUM(conn)) && > smb_fname->st.st_ex_iflags & ST_EX_IFLAG_CALCULATED_FILE_ID) >@@ -4322,7 +4322,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn, > return NT_STATUS_NOT_A_DIRECTORY; > } > >- smb_dname->st.st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_ITIME; >+ create_random_itime(&smb_dname->st); > > if (lp_store_dos_attributes(SNUM(conn))) { > if (smb_dname->st.st_ex_iflags & ST_EX_IFLAG_CALCULATED_FILE_ID) >-- >2.30.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
slow
:
review-
Actions:
View
Attachments on
bug 14928
:
17061
|
17070
|
17071
|
17073
|
17074
|
17076
|
17077
|
17078