Skip to content

Commit 503ef5c

Browse files
ebiggersgregkh
authored andcommitted
lib/digsig: fix dereference of NULL user_key_payload
commit 192cabd6a296cbc57b3d8c05c4c89d87fc102506 upstream. digsig_verify() requests a user key, then accesses its payload. However, a revoked key has a NULL payload, and we failed to check for this. request_key() *does* skip revoked keys, but there is still a window where the key can be revoked before we acquire its semaphore. Fix it by checking for a NULL payload, treating it like a key which was already revoked at the time it was requested. Fixes: 051dbb9 ("crypto: digital signature verification support") Reviewed-by: James Morris <james.l.morris@oracle.com> Cc: Dmitry Kasatkin <dmitry.kasatkin@intel.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2b7e022 commit 503ef5c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/digsig.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ static int digsig_verify_rsa(struct key *key,
8787
down_read(&key->sem);
8888
ukp = user_key_payload(key);
8989

90+
if (!ukp) {
91+
/* key was revoked before we acquired its semaphore */
92+
err = -EKEYREVOKED;
93+
goto err1;
94+
}
95+
9096
if (ukp->datalen < sizeof(*pkh))
9197
goto err1;
9298

0 commit comments

Comments
 (0)