]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbindd: Update non cache entries keys (non_centry_keys)
authorPavel Filipenský <pfilipensky@samba.org>
Fri, 22 Mar 2024 12:51:06 +0000 (13:51 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 14 May 2024 21:04:57 +0000 (21:04 +0000)
This change does NOT affect WHAT and HOW is cached. It only avoids
undefined behavior for "NDR" and "TRUSTDOMCACHE" when processed in
wcache_flush_cache() and wbcache_upgrade_v1_to_v2().

winbindd_cache.tdb contains two types of entries:

1) cache entries (typed as 'struct cache_entry')
  - internal format is:           [ntstatus; sequence_number; timeout]

2) non cache entries (keys listed in non_centry_keys)
  - for "NDR" internal format is: [sequence_number; timeout]

Without this commit, "NDR" would be processed as the first type (instead
as the second type). E.g. in the stack below:

wcache_fetch_raw()
traverse_fn_cleanup()
wcache_flush_cache()

the triplet [ntstatus; sequence_number; timeout] would be initialized
from data containing only [sequence_number; timeout], leading to
mismatched values ('ntstatus' would be filled from 'sequence_number').

Anyway, current code is never calling wcache_flush_cache(), since
wcache_flush_cache() can be called only from get_cache() and get_cache()
will call it only if global/static wcache was not set yet. But wcache is
set very early in the main winbind (and all winbind children get it
after fork), sooner than any call of get_cache() can happen:

   #1 init_wcache + 0x19
   #2 initialize_winbindd_cache + 0x35
   #3 winbindd_cache_validate_and_initialize + 0x25
   #4 main + 0x806

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue May 14 21:04:57 UTC 2024 on atb-devel-224

source3/winbindd/winbindd_cache.c

index 0067f8bd2445fef152337c35420ed1eef51fd378..833862ab99eff06d4fd185383423776d2d25879b 100644 (file)
@@ -68,7 +68,9 @@ static bool opt_nocache = False;
  */
 
 static const char *non_centry_keys[] = {
+       "NDR/",
        "SEQNUM/",
+       "TRUSTDOMCACHE/",
        "WINBINDD_OFFLINE",
        WINBINDD_CACHE_VERSION_KEYSTR,
        NULL