diff options
Diffstat (limited to 'kernel/cred.c')
-rw-r--r-- | kernel/cred.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/kernel/cred.c b/kernel/cred.c index 24dd2f5104b1..006fcab009d5 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
@@ -199,6 +199,49 @@ void exit_creds(struct task_struct *tsk) | |||
199 | validate_creds(cred); | 199 | validate_creds(cred); |
200 | alter_cred_subscribers(cred, -1); | 200 | alter_cred_subscribers(cred, -1); |
201 | put_cred(cred); | 201 | put_cred(cred); |
202 | |||
203 | cred = (struct cred *) tsk->replacement_session_keyring; | ||
204 | if (cred) { | ||
205 | tsk->replacement_session_keyring = NULL; | ||
206 | validate_creds(cred); | ||
207 | put_cred(cred); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | /* | ||
212 | * Allocate blank credentials, such that the credentials can be filled in at a | ||
213 | * later date without risk of ENOMEM. | ||
214 | */ | ||
215 | struct cred *cred_alloc_blank(void) | ||
216 | { | ||
217 | struct cred *new; | ||
218 | |||
219 | new = kmem_cache_zalloc(cred_jar, GFP_KERNEL); | ||
220 | if (!new) | ||
221 | return NULL; | ||
222 | |||
223 | #ifdef CONFIG_KEYS | ||
224 | new->tgcred = kzalloc(sizeof(*new->tgcred), GFP_KERNEL); | ||
225 | if (!new->tgcred) { | ||
226 | kfree(new); | ||
227 | return NULL; | ||
228 | } | ||
229 | atomic_set(&new->tgcred->usage, 1); | ||
230 | #endif | ||
231 | |||
232 | atomic_set(&new->usage, 1); | ||
233 | |||
234 | if (security_cred_alloc_blank(new, GFP_KERNEL) < 0) | ||
235 | goto error; | ||
236 | |||
237 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
238 | new->magic = CRED_MAGIC; | ||
239 | #endif | ||
240 | return new; | ||
241 | |||
242 | error: | ||
243 | abort_creds(new); | ||
244 | return NULL; | ||
202 | } | 245 | } |
203 | 246 | ||
204 | /** | 247 | /** |