Skip to contentSkip to conversation

CRED: Missing put_cred() in prepare_kernel_cred()

PATCH New David Howells 1 participant 2 messages Jan 9, 2009 Credentials

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 CRED: Missing put_cred() in prepare_kernel_cred()

Missing put_cred() in the error handling path of prepare_kernel_cred().

---

 kernel/cred.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/cred.c +1 -0
index 480a61a..400e608 100644
@@ -530,6 +530,7 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
 
 error:
 	put_cred(new);
+	put_cred(old);
 	return NULL;
 }
 EXPORT_SYMBOL(prepare_kernel_cred);
#1 lore raw

PATCH 2/2 CRED: Must initialise the new creds in prepare_kernel_cred()

The newly allocated creds in prepare_kernel_cred() must be initialised before get_uid() and get_group_info() can access them. They should be copied from the old credentials.

---

 kernel/cred.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/cred.c +1 -0
index 400e608..3a03918 100644
@@ -507,6 +507,7 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
 	else
 		old = get_cred(&init_cred);
 
+	*new = *old;
 	get_uid(new->user);
 	get_group_info(new->group_info);