Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_thread.c
Show First 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | thread_cow_update(struct thread *td) | ||||
struct proc *p; | struct proc *p; | ||||
struct ucred *oldcred; | struct ucred *oldcred; | ||||
struct plimit *oldlimit; | struct plimit *oldlimit; | ||||
p = td->td_proc; | p = td->td_proc; | ||||
oldcred = NULL; | oldcred = NULL; | ||||
oldlimit = NULL; | oldlimit = NULL; | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (td->td_ucred != p->p_ucred) { | if (td->td_ucred != p->p_ucred && !TD_IS_SUGID(td)) { | ||||
oldcred = td->td_ucred; | oldcred = td->td_ucred; | ||||
td->td_ucred = crhold(p->p_ucred); | td->td_ucred = crhold(p->p_ucred); | ||||
} | } | ||||
if (td->td_limit != p->p_limit) { | if (td->td_limit != p->p_limit) { | ||||
oldlimit = td->td_limit; | oldlimit = td->td_limit; | ||||
td->td_limit = lim_hold(p->p_limit); | td->td_limit = lim_hold(p->p_limit); | ||||
} | } | ||||
td->td_cowgen = p->p_cowgen; | td->td_cowgen = p->p_cowgen; | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
if (oldcred != NULL) | if (oldcred != NULL) | ||||
crfree(oldcred); | crfree(oldcred); | ||||
if (oldlimit != NULL) | if (oldlimit != NULL) | ||||
lim_free(oldlimit); | lim_free(oldlimit); | ||||
} | } | ||||
mjg: My major gripe is here. I already noted manipulations below should be moved elsewhere. But more… | |||||
Done Inline ActionsI agree placing this here isn't ideal, the first intention wasn't to do this (see previous patch versions). jack_gandi.net: I agree placing this here isn't ideal, the first intention wasn't to do this (see previous… | |||||
/* | /* | ||||
* Discard the current thread and exit from its context. | * Discard the current thread and exit from its context. | ||||
* Always called with scheduler locked. | * Always called with scheduler locked. | ||||
* | * | ||||
* Because we can't free a thread while we're operating under its context, | * Because we can't free a thread while we're operating under its context, | ||||
* push the current thread into our CPU's deadthread holder. This means | * push the current thread into our CPU's deadthread holder. This means | ||||
* we needn't worry about someone else grabbing our context before we | * we needn't worry about someone else grabbing our context before we | ||||
▲ Show 20 Lines • Show All 754 Lines • Show Last 20 Lines |
My major gripe is here. I already noted manipulations below should be moved elsewhere. But more importantly they look extremely iffy. credentials are supposed to be copy-on-write -- after they are initialized, they never change. Yet here several changes are made and I don't see any assurance the creds being modified are not referenced elsewhere.