KEYS: Add a key type op to permit the key description to be vetted
Add a key type operation to permit the key type to vet the description of a new key that key_alloc() is about to allocate. The operation may reject the description if it wishes with an error of its choosing. If it does this, the key will not be allocated. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Mimi Zohar <zohar@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
committed by
James Morris
parent
633e804e89
commit
b9fffa3877
@@ -249,6 +249,14 @@ struct key *key_alloc(struct key_type *type, const char *desc,
|
||||
if (!desc || !*desc)
|
||||
goto error;
|
||||
|
||||
if (type->vet_description) {
|
||||
ret = type->vet_description(desc);
|
||||
if (ret < 0) {
|
||||
key = ERR_PTR(ret);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
desclen = strlen(desc) + 1;
|
||||
quotalen = desclen + type->def_datalen;
|
||||
|
||||
|
Reference in New Issue
Block a user