ima: fix reference leak in asymmetric_verify()
Subsystems (6)
PATCH 1/1 ima: fix reference leak in asymmetric_verify()
From: Eric Biggers <[email protected]>
Don't leak a reference to the key if its algorithm is unknown.
--- security/integrity/digsig_asymmetric.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
security/integrity/digsig_asymmetric.c +9 -6
@@ -109,22 +109,25 @@ int asymmetric_verify(struct key *keyring, const char *sig, pk =asymmetric_key_public_key (key); pks.pkey_algo = pk->pkey_algo; -if (!strcmp (pk->pkey_algo,"rsa" )) +if (!strcmp (pk->pkey_algo,"rsa" )) { pks.encoding ="pkcs1" ; -else if (!strncmp (pk->pkey_algo,"ecdsa-" ,6 )) + }else if (!strncmp (pk->pkey_algo,"ecdsa-" ,6 )) {/* edcsa-nist-p192 etc. */ pks.encoding ="x962" ; -else if (!strcmp (pk->pkey_algo,"ecrdsa" ) || - !strcmp (pk->pkey_algo,"sm2" )) + }else if (!strcmp (pk->pkey_algo,"ecrdsa" ) || + !strcmp (pk->pkey_algo,"sm2" )) { pks.encoding ="raw" ; -else -return -ENOPKG ; + }else { + ret = -ENOPKG ; + goto out; + } pks.digest = (u8 *)data; pks.digest_size = datalen; pks.s = hdr->sig; pks.s_size = siglen; ret =verify_signature (key, &pks); +out:key_put (key);pr_debug ("%s() = %d\n" , __func__, ret);return ret;
base-commit: feb7a43de5ef625ad74097d8fd3481d5dbc06a59
Signature · 1 line
2.34.1
Quoted 48 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Don't leak a reference to the key if its algorithm is unknown.
Fixes 947d70597236 ("ima: Support EC keys for signature verification")Cc <[email protected]> # v5.13+Signed-off-by Eric Biggers <[email protected]>--- security/integrity/digsig_asymmetric.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)security/integrity/digsig_asymmetric.c +9
-6@@ -109,22 +109,25 @@ int asymmetric_verify(struct key *keyring, const char *sig, pk =asymmetric_key_public_key (key); pks.pkey_algo = pk->pkey_algo; -if (!strcmp (pk->pkey_algo,"rsa" )) +if (!strcmp (pk->pkey_algo,"rsa" )) { pks.encoding ="pkcs1" ; -else if (!strncmp (pk->pkey_algo,"ecdsa-" ,6 )) + }else if (!strncmp (pk->pkey_algo,"ecdsa-" ,6 )) {/* edcsa-nist-p192 etc. */ pks.encoding ="x962" ; -else if (!strcmp (pk->pkey_algo,"ecrdsa" ) || - !strcmp (pk->pkey_algo,"sm2" )) + }else if (!strcmp (pk->pkey_algo,"ecrdsa" ) || + !strcmp (pk->pkey_algo,"sm2" )) { pks.encoding ="raw" ; -else -return -ENOPKG ; + }else { + ret = -ENOPKG ; + goto out; + } pks.digest = (u8 *)data; pks.digest_size = datalen; pks.s = hdr->sig; pks.s_size = siglen; ret =verify_signature (key, &pks); +out:key_put (key);pr_debug ("%s() = %d\n" , __func__, ret);return ret;
Quoted 1 line
base-commit:
feb7a43de5ef625ad74097d8fd3481d5dbc06a59
Hi Eric,
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Don't leak a reference to the key if its algorithm is unknown.
Fixes 947d70597236 ("ima: Support EC keys for signature verification")Cc <[email protected]> # v5.13+Signed-off-by Eric Biggers <[email protected]>
thanks,
Mimi
Quoted 5 lines · Mimi Zohar
Hi Eric,
Quoted 2 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Quoted 8 lines
Quoted 5 lines
Don't leak a reference to the key if its algorithm is unknown.
Fixes 947d70597236 ("ima: Support EC keys for signature verification")Cc <[email protected]> # v5.13+Signed-off-by Eric Biggers <[email protected]>Reviewed-by Mimi Zohar <[email protected]>
Thanks. You're intending to apply this patch, right? Or are you expecting someone else to? get_maintainer.pl didn't associate this file with IMA, but I see you sent out a patch to fix that
(https://lore.kernel.org/linux-integrity/[email protected]/T/#u).
- Eric
Mimi Zohar
maintainerQuoted 12 lines · Eric Biggers
Quoted 11 lines · Mimi Zohar
Hi Eric,
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Don't leak a reference to the key if its algorithm is unknown.
Fixes 947d70597236 ("ima: Support EC keys for signature verification")Cc <[email protected]> # v5.13+Signed-off-by Eric Biggers <[email protected]>
Quoted 7 lines
Quoted 2 lines
Reviewed-by Mimi Zohar <[email protected]>Thanks. You're intending to apply this patch, right? Or are you expecting someone else to? get_maintainer.pl didn't associate this file with IMA, but I see you sent out a patch to fix that
(https://lore.kernel.org/linux-integrity/[email protected]/T/#u).
Once the open window closes, I'll apply it.
Mimi
Hi Eric,
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Don't leak a reference to the key if its algorithm is unknown.
Fixes 947d70597236 ("ima: Support EC keys for signature verification")Cc <[email protected]> # v5.13+Signed-off-by Eric Biggers <[email protected]>
LGTM.
Best regards,
Tianjia