+ /*
+ * Delayed binding of thread credential to process credential.
+ *
+ * XXX This doesn't really belong here, but the i386 code has a
+ * XXX number of seemingly gratuitous structural differences that
+ * XXX make this the most appropriate place to do the work.
+ */
+ if (ut->uu_ucred != p->p_ucred &&
+ (ut->uu_flag & UT_SETUID) == 0) {
+ kauth_cred_t old = ut->uu_ucred;
+ proc_lock(p);
+ ut->uu_ucred = p->p_ucred;
+ kauth_cred_ref(ut->uu_ucred);
+ proc_unlock(p);
+ if (old != NOCRED)
+ kauth_cred_rele(old);
+ }
+