diff options
-rw-r--r-- | include/keys/user-type.h | 1 | ||||
-rw-r--r-- | security/keys/keyring.c | 21 | ||||
-rw-r--r-- | security/keys/user_defined.c | 25 |
3 files changed, 46 insertions, 1 deletions
diff --git a/include/keys/user-type.h b/include/keys/user-type.h index a3dae1803f45..c37c34275a44 100644 --- a/include/keys/user-type.h +++ b/include/keys/user-type.h | |||
@@ -37,6 +37,7 @@ extern struct key_type key_type_user; | |||
37 | extern int user_instantiate(struct key *key, const void *data, size_t datalen); | 37 | extern int user_instantiate(struct key *key, const void *data, size_t datalen); |
38 | extern int user_update(struct key *key, const void *data, size_t datalen); | 38 | extern int user_update(struct key *key, const void *data, size_t datalen); |
39 | extern int user_match(const struct key *key, const void *criterion); | 39 | extern int user_match(const struct key *key, const void *criterion); |
40 | extern void user_revoke(struct key *key); | ||
40 | extern void user_destroy(struct key *key); | 41 | extern void user_destroy(struct key *key); |
41 | extern void user_describe(const struct key *user, struct seq_file *m); | 42 | extern void user_describe(const struct key *user, struct seq_file *m); |
42 | extern long user_read(const struct key *key, | 43 | extern long user_read(const struct key *key, |
diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 6c282bd937e2..e8d02acc51e7 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c | |||
@@ -49,6 +49,7 @@ static inline unsigned keyring_hash(const char *desc) | |||
49 | static int keyring_instantiate(struct key *keyring, | 49 | static int keyring_instantiate(struct key *keyring, |
50 | const void *data, size_t datalen); | 50 | const void *data, size_t datalen); |
51 | static int keyring_match(const struct key *keyring, const void *criterion); | 51 | static int keyring_match(const struct key *keyring, const void *criterion); |
52 | static void keyring_revoke(struct key *keyring); | ||
52 | static void keyring_destroy(struct key *keyring); | 53 | static void keyring_destroy(struct key *keyring); |
53 | static void keyring_describe(const struct key *keyring, struct seq_file *m); | 54 | static void keyring_describe(const struct key *keyring, struct seq_file *m); |
54 | static long keyring_read(const struct key *keyring, | 55 | static long keyring_read(const struct key *keyring, |
@@ -59,6 +60,7 @@ struct key_type key_type_keyring = { | |||
59 | .def_datalen = sizeof(struct keyring_list), | 60 | .def_datalen = sizeof(struct keyring_list), |
60 | .instantiate = keyring_instantiate, | 61 | .instantiate = keyring_instantiate, |
61 | .match = keyring_match, | 62 | .match = keyring_match, |
63 | .revoke = keyring_revoke, | ||
62 | .destroy = keyring_destroy, | 64 | .destroy = keyring_destroy, |
63 | .describe = keyring_describe, | 65 | .describe = keyring_describe, |
64 | .read = keyring_read, | 66 | .read = keyring_read, |
@@ -953,3 +955,22 @@ int keyring_clear(struct key *keyring) | |||
953 | } /* end keyring_clear() */ | 955 | } /* end keyring_clear() */ |
954 | 956 | ||
955 | EXPORT_SYMBOL(keyring_clear); | 957 | EXPORT_SYMBOL(keyring_clear); |
958 | |||
959 | /*****************************************************************************/ | ||
960 | /* | ||
961 | * dispose of the links from a revoked keyring | ||
962 | * - called with the key sem write-locked | ||
963 | */ | ||
964 | static void keyring_revoke(struct key *keyring) | ||
965 | { | ||
966 | struct keyring_list *klist = keyring->payload.subscriptions; | ||
967 | |||
968 | /* adjust the quota */ | ||
969 | key_payload_reserve(keyring, 0); | ||
970 | |||
971 | if (klist) { | ||
972 | rcu_assign_pointer(keyring->payload.subscriptions, NULL); | ||
973 | call_rcu(&klist->rcu, keyring_clear_rcu_disposal); | ||
974 | } | ||
975 | |||
976 | } /* end keyring_revoke() */ | ||
diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c index 8e71895b97a7..5bbfdebb7acf 100644 --- a/security/keys/user_defined.c +++ b/security/keys/user_defined.c | |||
@@ -28,6 +28,7 @@ struct key_type key_type_user = { | |||
28 | .instantiate = user_instantiate, | 28 | .instantiate = user_instantiate, |
29 | .update = user_update, | 29 | .update = user_update, |
30 | .match = user_match, | 30 | .match = user_match, |
31 | .revoke = user_revoke, | ||
31 | .destroy = user_destroy, | 32 | .destroy = user_destroy, |
32 | .describe = user_describe, | 33 | .describe = user_describe, |
33 | .read = user_read, | 34 | .read = user_read, |
@@ -67,6 +68,7 @@ error: | |||
67 | return ret; | 68 | return ret; |
68 | 69 | ||
69 | } /* end user_instantiate() */ | 70 | } /* end user_instantiate() */ |
71 | |||
70 | EXPORT_SYMBOL_GPL(user_instantiate); | 72 | EXPORT_SYMBOL_GPL(user_instantiate); |
71 | 73 | ||
72 | /*****************************************************************************/ | 74 | /*****************************************************************************/ |
@@ -141,7 +143,28 @@ EXPORT_SYMBOL_GPL(user_match); | |||
141 | 143 | ||
142 | /*****************************************************************************/ | 144 | /*****************************************************************************/ |
143 | /* | 145 | /* |
144 | * dispose of the data dangling from the corpse of a user | 146 | * dispose of the links from a revoked keyring |
147 | * - called with the key sem write-locked | ||
148 | */ | ||
149 | void user_revoke(struct key *key) | ||
150 | { | ||
151 | struct user_key_payload *upayload = key->payload.data; | ||
152 | |||
153 | /* clear the quota */ | ||
154 | key_payload_reserve(key, 0); | ||
155 | |||
156 | if (upayload) { | ||
157 | rcu_assign_pointer(key->payload.data, NULL); | ||
158 | call_rcu(&upayload->rcu, user_update_rcu_disposal); | ||
159 | } | ||
160 | |||
161 | } /* end user_revoke() */ | ||
162 | |||
163 | EXPORT_SYMBOL(user_revoke); | ||
164 | |||
165 | /*****************************************************************************/ | ||
166 | /* | ||
167 | * dispose of the data dangling from the corpse of a user key | ||
145 | */ | 168 | */ |
146 | void user_destroy(struct key *key) | 169 | void user_destroy(struct key *key) |
147 | { | 170 | { |