latchset/clevis

PKCS#11: Multi-thread lock evasion issue detected on clevis-pkcs11-afunix-socket-unlock.c

sarroutbi opened this issue · 0 comments

An issue related to the lock of the entry_counter variable is detected by static analysis tool. This should be fixed by locking the hole function appropriately:

Error: LOCK_EVASION: clevis-21/src/pins/pkcs11/clevis-pkcs11-afunix-socket-unlock.c:83:23: 
use_same_locks_for_read_and_modify: Guard the modification of "entry_counter" and the read
used to decide whether to modify "entry_counter" with the same set of locks.
#   86|       }
#   87|       pthread_mutex_lock(&mutex);
#   88|->     strncpy(keys[entry_counter++].key, key, MAX_KEY);
#   89|       pthread_mutex_unlock(&mutex);
#   90|   }