libtom / libtomcrypt

LibTomCrypt is a fairly comprehensive, modular and portable cryptographic toolkit that provides developers with a vast array of well known published block ciphers, one-way hash functions, chaining modes, pseudo-random number generators, public key cryptography and a plethora of other routines.

Home Page:https://www.libtom.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An improper locking bug(e.g., deadlock) on the lock ltc_ecc_fp_lock

ycaibb opened this issue · comments

commented

Hi, developers, thank you for your checking. It seems the lock ltc_ecc_fp_lock is not released correctly when cache_entry == NULL in the function ltc_ecc_fp_save_state?

LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
/*
* build the list;
Cache DEFINITIONS ::=
BEGIN
CacheDump ::= SEQUENCE {
numEntries SHORTINTEGER,
maxEntries SHORTINTEGER,
numLUT SHORTINTEGER,
cache SEQUENCE OF INTEGER
}
END
*
*/
/*
* The cache itself is a point (3 INTEGERS),
* the LUT as pairs of INTEGERS (2 * 1<<FP_LUT),
* and the mu INTEGER
*/
cache_entry = XCALLOC(FP_ENTRIES*(2*(1U<<FP_LUT)+4)+3, sizeof(ltc_asn1_list));
if (cache_entry == NULL)
return CRYPT_MEM;

commented

Hi, developers @sjaeckel @fperrad @karel-m

Any comments would be highly appreciated. Thank you.

Best Regards,

btw. referring to OP-TEE/optee_os#4842 would have been nice :)

looks fine, I'll apply the patch you posted to optee

commented

@sjaeckel Thanks~

Can you please check whether #626 correctly fixes this?

commented

It looks good to me.