From: Vinay Gannevaram Date: Thu, 21 Jul 2022 14:47:26 +0000 (+0530) Subject: Fix expiration logic for the first PTKSA cache entry X-Git-Tag: hostap_2_11~1735 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f8af5974c1b52b473fe910f0bc772e356c6fd98;p=thirdparty%2Fhostap.git Fix expiration logic for the first PTKSA cache entry When an entry is added to the PTKSA cache, timer expiration is not set. Check the list and set the timer expiration when the list is empty also. When another entry is added to the list, it is placed before the relavant entry in the order of expiry time of all entries present in the list. Fixes: a4e36916168a ("WPA: Add PTKSA cache implementation") Signed-off-by: Jouni Malinen --- diff --git a/src/common/ptksa_cache.c b/src/common/ptksa_cache.c index d5f8b7805..aacc42512 100644 --- a/src/common/ptksa_cache.c +++ b/src/common/ptksa_cache.c @@ -281,6 +281,7 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa, { struct ptksa_cache_entry *entry, *tmp, *tmp2 = NULL; struct os_reltime now; + bool set_expiry = false; if (!ptksa || !ptk || !addr || !life_time || cipher == WPA_CIPHER_NONE) return NULL; @@ -317,6 +318,8 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa, } } + if (dl_list_empty(&entry->list)) + set_expiry = true; /* * If the expiration is later then all other or the list is empty * entries, add it to the end of the list; @@ -332,5 +335,8 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa, "Added PTKSA cache entry addr=" MACSTR " cipher=%u", MAC2STR(addr), cipher); + if (set_expiry) + ptksa_cache_set_expiration(ptksa); + return entry; }