KEYS: fix cred refcount leak in request_key_auth_new()
Subsystems (2)
PATCH 1/1 KEYS: fix cred refcount leak in request_key_auth_new()
From: Eric Biggers <[email protected]>
In request_key_auth_new(), if alloc_key() or key_instantiate_and_link() were to fail, we would leak a reference to the 'struct cred'. Currently this can only happen if alloc_key() fails to to allocate memory. But it still should be fixed, as it is a more severe bug waiting to happen.
--- security/keys/request_key_auth.c | 1 + 1 file changed, 1 insertion(+)
security/keys/request_key_auth.c +1 -0
@@ -227,6 +227,7 @@ struct key *request_key_auth_new(struct key *target, const void *callout_info,key_revoke (authkey);key_put (authkey); error_alloc: +put_cred (rka->cred);key_put (rka->target_key);key_put (rka->dest_keyring);kfree (rka->callout_info);
Signature · 1 line
2.14.1.690.gbb1197296e-goog
David Howells
maintainerQuoted 4 lines · Eric Biggers
In
request_key_auth_new(), ifalloc_key()orkey_instantiate_and_link()were to fail, we would leak a reference to the 'struct cred'. Currently this can only happen ifalloc_key()fails to to allocate memory. But it still should be fixed, as it is a more severe bug waiting to happen.
It might be better to combine request_key_auth_destroy() and the error path that you're altering in request_key_auth_new() by pulling it into a separate function.
David
Quoted 7 lines · David Howells
Quoted 4 lines · Eric Biggers
In
request_key_auth_new(), ifalloc_key()orkey_instantiate_and_link()were to fail, we would leak a reference to the 'struct cred'. Currently this can only happen ifalloc_key()fails to to allocate memory. But it still should be fixed, as it is a more severe bug waiting to happen.
Quoted 5 lines
It might be better to combine
request_key_auth_destroy()and the error path that you're altering inrequest_key_auth_new()by pulling it into a separate function.David
Agreed, I'll do that.
Eric