aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/asymmetric_keys/asymmetric_type.c6
-rw-r--r--crypto/asymmetric_keys/pkcs7_key_type.c1
-rw-r--r--fs/cifs/cifs_spnego.c1
-rw-r--r--fs/cifs/cifsacl.c1
-rw-r--r--fs/nfs/idmap.c2
-rw-r--r--include/keys/user-type.h3
-rw-r--r--include/linux/key-type.h4
-rw-r--r--net/ceph/crypto.c1
-rw-r--r--net/dns_resolver/dns_key.c17
-rw-r--r--net/rxrpc/ar-key.c2
-rw-r--r--security/keys/big_key.c1
-rw-r--r--security/keys/encrypted-keys/encrypted.c1
-rw-r--r--security/keys/internal.h2
-rw-r--r--security/keys/key.c2
-rw-r--r--security/keys/keyring.c15
-rw-r--r--security/keys/request_key.c2
-rw-r--r--security/keys/request_key_auth.c2
-rw-r--r--security/keys/trusted.c1
-rw-r--r--security/keys/user_defined.c12
19 files changed, 31 insertions, 45 deletions
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index 9d78ad7754d9..7c0498968975 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -59,8 +59,8 @@ EXPORT_SYMBOL_GPL(asymmetric_keyid_match);
59 * "id:<id>" - request a key matching the ID 59 * "id:<id>" - request a key matching the ID
60 * "<subtype>:<id>" - request a key of a subtype 60 * "<subtype>:<id>" - request a key of a subtype
61 */ 61 */
62static int asymmetric_key_match(const struct key *key, 62static int asymmetric_key_cmp(const struct key *key,
63 const struct key_match_data *match_data) 63 const struct key_match_data *match_data)
64{ 64{
65 const struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); 65 const struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key);
66 const char *description = match_data->raw_data; 66 const char *description = match_data->raw_data;
@@ -110,6 +110,7 @@ static int asymmetric_key_match(const struct key *key,
110static int asymmetric_key_match_preparse(struct key_match_data *match_data) 110static int asymmetric_key_match_preparse(struct key_match_data *match_data)
111{ 111{
112 match_data->lookup_type = KEYRING_SEARCH_LOOKUP_ITERATE; 112 match_data->lookup_type = KEYRING_SEARCH_LOOKUP_ITERATE;
113 match_data->cmp = asymmetric_key_cmp;
113 return 0; 114 return 0;
114} 115}
115 116
@@ -224,7 +225,6 @@ struct key_type key_type_asymmetric = {
224 .free_preparse = asymmetric_key_free_preparse, 225 .free_preparse = asymmetric_key_free_preparse,
225 .instantiate = generic_key_instantiate, 226 .instantiate = generic_key_instantiate,
226 .match_preparse = asymmetric_key_match_preparse, 227 .match_preparse = asymmetric_key_match_preparse,
227 .match = asymmetric_key_match,
228 .match_free = asymmetric_key_match_free, 228 .match_free = asymmetric_key_match_free,
229 .destroy = asymmetric_key_destroy, 229 .destroy = asymmetric_key_destroy,
230 .describe = asymmetric_key_describe, 230 .describe = asymmetric_key_describe,
diff --git a/crypto/asymmetric_keys/pkcs7_key_type.c b/crypto/asymmetric_keys/pkcs7_key_type.c
index d1faa1df1dec..751f8fd7335d 100644
--- a/crypto/asymmetric_keys/pkcs7_key_type.c
+++ b/crypto/asymmetric_keys/pkcs7_key_type.c
@@ -75,7 +75,6 @@ static struct key_type key_type_pkcs7 = {
75 .preparse = pkcs7_preparse, 75 .preparse = pkcs7_preparse,
76 .free_preparse = user_free_preparse, 76 .free_preparse = user_free_preparse,
77 .instantiate = generic_key_instantiate, 77 .instantiate = generic_key_instantiate,
78 .match = user_match,
79 .revoke = user_revoke, 78 .revoke = user_revoke,
80 .destroy = user_destroy, 79 .destroy = user_destroy,
81 .describe = user_describe, 80 .describe = user_describe,
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c
index a3e932547617..f4cf200b3c76 100644
--- a/fs/cifs/cifs_spnego.c
+++ b/fs/cifs/cifs_spnego.c
@@ -62,7 +62,6 @@ cifs_spnego_key_destroy(struct key *key)
62struct key_type cifs_spnego_key_type = { 62struct key_type cifs_spnego_key_type = {
63 .name = "cifs.spnego", 63 .name = "cifs.spnego",
64 .instantiate = cifs_spnego_key_instantiate, 64 .instantiate = cifs_spnego_key_instantiate,
65 .match = user_match,
66 .destroy = cifs_spnego_key_destroy, 65 .destroy = cifs_spnego_key_destroy,
67 .describe = user_describe, 66 .describe = user_describe,
68}; 67};
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 7ff866dbb89e..6d00c419cbae 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -84,7 +84,6 @@ static struct key_type cifs_idmap_key_type = {
84 .instantiate = cifs_idmap_key_instantiate, 84 .instantiate = cifs_idmap_key_instantiate,
85 .destroy = cifs_idmap_key_destroy, 85 .destroy = cifs_idmap_key_destroy,
86 .describe = user_describe, 86 .describe = user_describe,
87 .match = user_match,
88}; 87};
89 88
90static char * 89static char *
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 7dd55b745c4d..2f5db844c172 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -177,7 +177,6 @@ static struct key_type key_type_id_resolver = {
177 .preparse = user_preparse, 177 .preparse = user_preparse,
178 .free_preparse = user_free_preparse, 178 .free_preparse = user_free_preparse,
179 .instantiate = generic_key_instantiate, 179 .instantiate = generic_key_instantiate,
180 .match = user_match,
181 .revoke = user_revoke, 180 .revoke = user_revoke,
182 .destroy = user_destroy, 181 .destroy = user_destroy,
183 .describe = user_describe, 182 .describe = user_describe,
@@ -401,7 +400,6 @@ static struct key_type key_type_id_resolver_legacy = {
401 .preparse = user_preparse, 400 .preparse = user_preparse,
402 .free_preparse = user_free_preparse, 401 .free_preparse = user_free_preparse,
403 .instantiate = generic_key_instantiate, 402 .instantiate = generic_key_instantiate,
404 .match = user_match,
405 .revoke = user_revoke, 403 .revoke = user_revoke,
406 .destroy = user_destroy, 404 .destroy = user_destroy,
407 .describe = user_describe, 405 .describe = user_describe,
diff --git a/include/keys/user-type.h b/include/keys/user-type.h
index 66d92af30e7c..cebefb069c44 100644
--- a/include/keys/user-type.h
+++ b/include/keys/user-type.h
@@ -36,13 +36,10 @@ extern struct key_type key_type_user;
36extern struct key_type key_type_logon; 36extern struct key_type key_type_logon;
37 37
38struct key_preparsed_payload; 38struct key_preparsed_payload;
39struct key_match_data;
40 39
41extern int user_preparse(struct key_preparsed_payload *prep); 40extern int user_preparse(struct key_preparsed_payload *prep);
42extern void user_free_preparse(struct key_preparsed_payload *prep); 41extern void user_free_preparse(struct key_preparsed_payload *prep);
43extern int user_update(struct key *key, struct key_preparsed_payload *prep); 42extern int user_update(struct key *key, struct key_preparsed_payload *prep);
44extern int user_match(const struct key *key,
45 const struct key_match_data *match_data);
46extern void user_revoke(struct key *key); 43extern void user_revoke(struct key *key);
47extern void user_destroy(struct key *key); 44extern void user_destroy(struct key *key);
48extern void user_describe(const struct key *user, struct seq_file *m); 45extern void user_describe(const struct key *user, struct seq_file *m);
diff --git a/include/linux/key-type.h b/include/linux/key-type.h
index bf93ea609273..c14816bd3b44 100644
--- a/include/linux/key-type.h
+++ b/include/linux/key-type.h
@@ -113,10 +113,6 @@ struct key_type {
113 */ 113 */
114 int (*match_preparse)(struct key_match_data *match_data); 114 int (*match_preparse)(struct key_match_data *match_data);
115 115
116 /* match a key against a description */
117 int (*match)(const struct key *key,
118 const struct key_match_data *match_data);
119
120 /* Free preparsed match data (optional). This should be supplied it 116 /* Free preparsed match data (optional). This should be supplied it
121 * ->match_preparse() is supplied. */ 117 * ->match_preparse() is supplied. */
122 void (*match_free)(struct key_match_data *match_data); 118 void (*match_free)(struct key_match_data *match_data);
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index ffeba8f9dda9..62fc5e7a9acf 100644
--- a/net/ceph/crypto.c
+++ b/net/ceph/crypto.c
@@ -476,7 +476,6 @@ struct key_type key_type_ceph = {
476 .preparse = ceph_key_preparse, 476 .preparse = ceph_key_preparse,
477 .free_preparse = ceph_key_free_preparse, 477 .free_preparse = ceph_key_free_preparse,
478 .instantiate = generic_key_instantiate, 478 .instantiate = generic_key_instantiate,
479 .match = user_match,
480 .destroy = ceph_key_destroy, 479 .destroy = ceph_key_destroy,
481}; 480};
482 481
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 92df6e508ae7..a07b9ba7e0b7 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -176,9 +176,8 @@ static void dns_resolver_free_preparse(struct key_preparsed_payload *prep)
176 * The domain name may be a simple name or an absolute domain name (which 176 * The domain name may be a simple name or an absolute domain name (which
177 * should end with a period). The domain name is case-independent. 177 * should end with a period). The domain name is case-independent.
178 */ 178 */
179static int 179static int dns_resolver_cmp(const struct key *key,
180dns_resolver_match(const struct key *key, 180 const struct key_match_data *match_data)
181 const struct key_match_data *match_data)
182{ 181{
183 int slen, dlen, ret = 0; 182 int slen, dlen, ret = 0;
184 const char *src = key->description, *dsp = match_data->raw_data; 183 const char *src = key->description, *dsp = match_data->raw_data;
@@ -210,6 +209,16 @@ no_match:
210} 209}
211 210
212/* 211/*
212 * Preparse the match criterion.
213 */
214static int dns_resolver_match_preparse(struct key_match_data *match_data)
215{
216 match_data->lookup_type = KEYRING_SEARCH_LOOKUP_ITERATE;
217 match_data->cmp = dns_resolver_cmp;
218 return 0;
219}
220
221/*
213 * Describe a DNS key 222 * Describe a DNS key
214 */ 223 */
215static void dns_resolver_describe(const struct key *key, struct seq_file *m) 224static void dns_resolver_describe(const struct key *key, struct seq_file *m)
@@ -243,7 +252,7 @@ struct key_type key_type_dns_resolver = {
243 .preparse = dns_resolver_preparse, 252 .preparse = dns_resolver_preparse,
244 .free_preparse = dns_resolver_free_preparse, 253 .free_preparse = dns_resolver_free_preparse,
245 .instantiate = generic_key_instantiate, 254 .instantiate = generic_key_instantiate,
246 .match = dns_resolver_match, 255 .match_preparse = dns_resolver_match_preparse,
247 .revoke = user_revoke, 256 .revoke = user_revoke,
248 .destroy = user_destroy, 257 .destroy = user_destroy,
249 .describe = dns_resolver_describe, 258 .describe = dns_resolver_describe,
diff --git a/net/rxrpc/ar-key.c b/net/rxrpc/ar-key.c
index 3907add75932..10c6cb694b43 100644
--- a/net/rxrpc/ar-key.c
+++ b/net/rxrpc/ar-key.c
@@ -44,7 +44,6 @@ struct key_type key_type_rxrpc = {
44 .preparse = rxrpc_preparse, 44 .preparse = rxrpc_preparse,
45 .free_preparse = rxrpc_free_preparse, 45 .free_preparse = rxrpc_free_preparse,
46 .instantiate = generic_key_instantiate, 46 .instantiate = generic_key_instantiate,
47 .match = user_match,
48 .destroy = rxrpc_destroy, 47 .destroy = rxrpc_destroy,
49 .describe = rxrpc_describe, 48 .describe = rxrpc_describe,
50 .read = rxrpc_read, 49 .read = rxrpc_read,
@@ -61,7 +60,6 @@ struct key_type key_type_rxrpc_s = {
61 .preparse = rxrpc_preparse_s, 60 .preparse = rxrpc_preparse_s,
62 .free_preparse = rxrpc_free_preparse_s, 61 .free_preparse = rxrpc_free_preparse_s,
63 .instantiate = generic_key_instantiate, 62 .instantiate = generic_key_instantiate,
64 .match = user_match,
65 .destroy = rxrpc_destroy_s, 63 .destroy = rxrpc_destroy_s,
66 .describe = rxrpc_describe, 64 .describe = rxrpc_describe,
67}; 65};
diff --git a/security/keys/big_key.c b/security/keys/big_key.c
index 4045c13a761a..b6adb94f6d52 100644
--- a/security/keys/big_key.c
+++ b/security/keys/big_key.c
@@ -36,7 +36,6 @@ struct key_type key_type_big_key = {
36 .preparse = big_key_preparse, 36 .preparse = big_key_preparse,
37 .free_preparse = big_key_free_preparse, 37 .free_preparse = big_key_free_preparse,
38 .instantiate = generic_key_instantiate, 38 .instantiate = generic_key_instantiate,
39 .match = user_match,
40 .revoke = big_key_revoke, 39 .revoke = big_key_revoke,
41 .destroy = big_key_destroy, 40 .destroy = big_key_destroy,
42 .describe = big_key_describe, 41 .describe = big_key_describe,
diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
index 5fe443d120af..db9675db1026 100644
--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -970,7 +970,6 @@ struct key_type key_type_encrypted = {
970 .name = "encrypted", 970 .name = "encrypted",
971 .instantiate = encrypted_instantiate, 971 .instantiate = encrypted_instantiate,
972 .update = encrypted_update, 972 .update = encrypted_update,
973 .match = user_match,
974 .destroy = encrypted_destroy, 973 .destroy = encrypted_destroy,
975 .describe = user_describe, 974 .describe = user_describe,
976 .read = encrypted_read, 975 .read = encrypted_read,
diff --git a/security/keys/internal.h b/security/keys/internal.h
index b47cc532be1e..e66a16cb63e1 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -127,6 +127,8 @@ struct keyring_search_context {
127 struct timespec now; 127 struct timespec now;
128}; 128};
129 129
130extern int key_default_cmp(const struct key *key,
131 const struct key_match_data *match_data);
130extern key_ref_t keyring_search_aux(key_ref_t keyring_ref, 132extern key_ref_t keyring_search_aux(key_ref_t keyring_ref,
131 struct keyring_search_context *ctx); 133 struct keyring_search_context *ctx);
132 134
diff --git a/security/keys/key.c b/security/keys/key.c
index b90a68c4e2c4..8c0092ca0443 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -799,7 +799,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
799 } 799 }
800 800
801 key_ref = ERR_PTR(-EINVAL); 801 key_ref = ERR_PTR(-EINVAL);
802 if (!index_key.type->match || !index_key.type->instantiate || 802 if (!index_key.type->instantiate ||
803 (!index_key.description && !index_key.type->preparse)) 803 (!index_key.description && !index_key.type->preparse))
804 goto error_put_type; 804 goto error_put_type;
805 805
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 10f0a5f2d362..253c9a0eb092 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -89,7 +89,6 @@ struct key_type key_type_keyring = {
89 .preparse = keyring_preparse, 89 .preparse = keyring_preparse,
90 .free_preparse = keyring_free_preparse, 90 .free_preparse = keyring_free_preparse,
91 .instantiate = keyring_instantiate, 91 .instantiate = keyring_instantiate,
92 .match = user_match,
93 .revoke = keyring_revoke, 92 .revoke = keyring_revoke,
94 .destroy = keyring_destroy, 93 .destroy = keyring_destroy,
95 .describe = keyring_describe, 94 .describe = keyring_describe,
@@ -512,6 +511,15 @@ struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid,
512EXPORT_SYMBOL(keyring_alloc); 511EXPORT_SYMBOL(keyring_alloc);
513 512
514/* 513/*
514 * By default, we keys found by getting an exact match on their descriptions.
515 */
516int key_default_cmp(const struct key *key,
517 const struct key_match_data *match_data)
518{
519 return strcmp(key->description, match_data->raw_data) == 0;
520}
521
522/*
515 * Iteration function to consider each key found. 523 * Iteration function to consider each key found.
516 */ 524 */
517static int keyring_search_iterator(const void *object, void *iterator_data) 525static int keyring_search_iterator(const void *object, void *iterator_data)
@@ -884,7 +892,7 @@ key_ref_t keyring_search(key_ref_t keyring,
884 .index_key.type = type, 892 .index_key.type = type,
885 .index_key.description = description, 893 .index_key.description = description,
886 .cred = current_cred(), 894 .cred = current_cred(),
887 .match_data.cmp = type->match, 895 .match_data.cmp = key_default_cmp,
888 .match_data.raw_data = description, 896 .match_data.raw_data = description,
889 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT, 897 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT,
890 .flags = KEYRING_SEARCH_DO_STATE_CHECK, 898 .flags = KEYRING_SEARCH_DO_STATE_CHECK,
@@ -892,9 +900,6 @@ key_ref_t keyring_search(key_ref_t keyring,
892 key_ref_t key; 900 key_ref_t key;
893 int ret; 901 int ret;
894 902
895 if (!ctx.match_data.cmp)
896 return ERR_PTR(-ENOKEY);
897
898 if (type->match_preparse) { 903 if (type->match_preparse) {
899 ret = type->match_preparse(&ctx.match_data); 904 ret = type->match_preparse(&ctx.match_data);
900 if (ret < 0) 905 if (ret < 0)
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 408523e5e2e2..dc6ed32b7844 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -531,7 +531,7 @@ struct key *request_key_and_link(struct key_type *type,
531 .index_key.type = type, 531 .index_key.type = type,
532 .index_key.description = description, 532 .index_key.description = description,
533 .cred = current_cred(), 533 .cred = current_cred(),
534 .match_data.cmp = type->match, 534 .match_data.cmp = key_default_cmp,
535 .match_data.raw_data = description, 535 .match_data.raw_data = description,
536 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT, 536 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT,
537 }; 537 };
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index 9ae02819cc06..6639e2cb8853 100644
--- a/security/keys/request_key_auth.c
+++ b/security/keys/request_key_auth.c
@@ -246,7 +246,7 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id)
246 .index_key.type = &key_type_request_key_auth, 246 .index_key.type = &key_type_request_key_auth,
247 .index_key.description = description, 247 .index_key.description = description,
248 .cred = current_cred(), 248 .cred = current_cred(),
249 .match_data.cmp = user_match, 249 .match_data.cmp = key_default_cmp,
250 .match_data.raw_data = description, 250 .match_data.raw_data = description,
251 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT, 251 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT,
252 }; 252 };
diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index 6b804aa4529a..c0594cb07ada 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -1096,7 +1096,6 @@ struct key_type key_type_trusted = {
1096 .name = "trusted", 1096 .name = "trusted",
1097 .instantiate = trusted_instantiate, 1097 .instantiate = trusted_instantiate,
1098 .update = trusted_update, 1098 .update = trusted_update,
1099 .match = user_match,
1100 .destroy = trusted_destroy, 1099 .destroy = trusted_destroy,
1101 .describe = user_describe, 1100 .describe = user_describe,
1102 .read = trusted_read, 1101 .read = trusted_read,
diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c
index cd7e726e8646..36b47bbd3d8c 100644
--- a/security/keys/user_defined.c
+++ b/security/keys/user_defined.c
@@ -30,7 +30,6 @@ struct key_type key_type_user = {
30 .free_preparse = user_free_preparse, 30 .free_preparse = user_free_preparse,
31 .instantiate = generic_key_instantiate, 31 .instantiate = generic_key_instantiate,
32 .update = user_update, 32 .update = user_update,
33 .match = user_match,
34 .revoke = user_revoke, 33 .revoke = user_revoke,
35 .destroy = user_destroy, 34 .destroy = user_destroy,
36 .describe = user_describe, 35 .describe = user_describe,
@@ -51,7 +50,6 @@ struct key_type key_type_logon = {
51 .free_preparse = user_free_preparse, 50 .free_preparse = user_free_preparse,
52 .instantiate = generic_key_instantiate, 51 .instantiate = generic_key_instantiate,
53 .update = user_update, 52 .update = user_update,
54 .match = user_match,
55 .revoke = user_revoke, 53 .revoke = user_revoke,
56 .destroy = user_destroy, 54 .destroy = user_destroy,
57 .describe = user_describe, 55 .describe = user_describe,
@@ -137,16 +135,6 @@ error:
137EXPORT_SYMBOL_GPL(user_update); 135EXPORT_SYMBOL_GPL(user_update);
138 136
139/* 137/*
140 * match users on their name
141 */
142int user_match(const struct key *key, const struct key_match_data *match_data)
143{
144 return strcmp(key->description, match_data->raw_data) == 0;
145}
146
147EXPORT_SYMBOL_GPL(user_match);
148
149/*
150 * dispose of the links from a revoked keyring 138 * dispose of the links from a revoked keyring
151 * - called with the key sem write-locked 139 * - called with the key sem write-locked
152 */ 140 */