diff options
Diffstat (limited to 'security/keys/request_key.c')
| -rw-r--r-- | security/keys/request_key.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 26a94f18af94..bb4337c7ae1b 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c | |||
| @@ -513,9 +513,9 @@ struct key *request_key_and_link(struct key_type *type, | |||
| 513 | .index_key.type = type, | 513 | .index_key.type = type, |
| 514 | .index_key.description = description, | 514 | .index_key.description = description, |
| 515 | .cred = current_cred(), | 515 | .cred = current_cred(), |
| 516 | .match = type->match, | 516 | .match_data.cmp = key_default_cmp, |
| 517 | .match_data = description, | 517 | .match_data.raw_data = description, |
| 518 | .flags = KEYRING_SEARCH_LOOKUP_DIRECT, | 518 | .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT, |
| 519 | }; | 519 | }; |
| 520 | struct key *key; | 520 | struct key *key; |
| 521 | key_ref_t key_ref; | 521 | key_ref_t key_ref; |
| @@ -525,6 +525,14 @@ struct key *request_key_and_link(struct key_type *type, | |||
| 525 | ctx.index_key.type->name, ctx.index_key.description, | 525 | ctx.index_key.type->name, ctx.index_key.description, |
| 526 | callout_info, callout_len, aux, dest_keyring, flags); | 526 | callout_info, callout_len, aux, dest_keyring, flags); |
| 527 | 527 | ||
| 528 | if (type->match_preparse) { | ||
| 529 | ret = type->match_preparse(&ctx.match_data); | ||
| 530 | if (ret < 0) { | ||
| 531 | key = ERR_PTR(ret); | ||
| 532 | goto error; | ||
| 533 | } | ||
| 534 | } | ||
| 535 | |||
| 528 | /* search all the process keyrings for a key */ | 536 | /* search all the process keyrings for a key */ |
| 529 | key_ref = search_process_keyrings(&ctx); | 537 | key_ref = search_process_keyrings(&ctx); |
| 530 | 538 | ||
| @@ -537,7 +545,7 @@ struct key *request_key_and_link(struct key_type *type, | |||
| 537 | if (ret < 0) { | 545 | if (ret < 0) { |
| 538 | key_put(key); | 546 | key_put(key); |
| 539 | key = ERR_PTR(ret); | 547 | key = ERR_PTR(ret); |
| 540 | goto error; | 548 | goto error_free; |
| 541 | } | 549 | } |
| 542 | } | 550 | } |
| 543 | } else if (PTR_ERR(key_ref) != -EAGAIN) { | 551 | } else if (PTR_ERR(key_ref) != -EAGAIN) { |
| @@ -547,12 +555,15 @@ struct key *request_key_and_link(struct key_type *type, | |||
| 547 | * should consult userspace if we can */ | 555 | * should consult userspace if we can */ |
| 548 | key = ERR_PTR(-ENOKEY); | 556 | key = ERR_PTR(-ENOKEY); |
| 549 | if (!callout_info) | 557 | if (!callout_info) |
| 550 | goto error; | 558 | goto error_free; |
| 551 | 559 | ||
| 552 | key = construct_key_and_link(&ctx, callout_info, callout_len, | 560 | key = construct_key_and_link(&ctx, callout_info, callout_len, |
| 553 | aux, dest_keyring, flags); | 561 | aux, dest_keyring, flags); |
| 554 | } | 562 | } |
| 555 | 563 | ||
| 564 | error_free: | ||
| 565 | if (type->match_free) | ||
| 566 | type->match_free(&ctx.match_data); | ||
| 556 | error: | 567 | error: |
| 557 | kleave(" = %p", key); | 568 | kleave(" = %p", key); |
| 558 | return key; | 569 | return key; |
