diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1850,6 +1850,15 @@ * Changing td_realucred into something else decrements cr_users and transfers * accumulated updates. */ + +#if defined(__ILP32__) +#define CR_REF_FORMAT "%d" +#elif defined(__LP64__) +#define CR_REF_FORMAT "%ld" +#else +#error unknown data model +#endif + struct ucred * crcowget(struct ucred *cr) { @@ -1877,7 +1886,7 @@ __func__, cr->cr_users, cr)); cr->cr_users--; if (cr->cr_users == 0) { - KASSERT(cr->cr_ref > 0, ("%s: ref %d not > 0 on cred %p", + KASSERT(cr->cr_ref > 0, ("%s: ref " CR_REF_FORMAT " not > 0 on cred %p", __func__, cr->cr_ref, cr)); crold = cr; } else { @@ -1905,7 +1914,7 @@ mtx_unlock(&cr->cr_mtx); return; } - KASSERT(cr->cr_ref >= 0, ("%s: ref %d not >= 0 on cred %p", + KASSERT(cr->cr_ref >= 0, ("%s: ref " CR_REF_FORMAT " not >= 0 on cred %p", __func__, cr->cr_ref, cr)); if (cr->cr_ref > 0) { mtx_unlock(&cr->cr_mtx); @@ -2051,7 +2060,7 @@ mtx_unlock(&cr->cr_mtx); return; } - KASSERT(cr->cr_ref >= 0, ("%s: ref %d not >= 0 on cred %p", + KASSERT(cr->cr_ref >= 0, ("%s: ref " CR_REF_FORMAT " not >= 0 on cred %p", __func__, cr->cr_ref, cr)); if (cr->cr_ref > 0) { mtx_unlock(&cr->cr_mtx); @@ -2066,7 +2075,7 @@ KASSERT(cr->cr_users == 0, ("%s: users %d not == 0 on cred %p", __func__, cr->cr_users, cr)); - KASSERT(cr->cr_ref == 0, ("%s: ref %d not == 0 on cred %p", + KASSERT(cr->cr_ref == 0, ("%s: ref " CR_REF_FORMAT " not == 0 on cred %p", __func__, cr->cr_ref, cr)); /* @@ -2104,6 +2113,7 @@ bcopy(&src->cr_startcopy, &dest->cr_startcopy, (unsigned)((caddr_t)&src->cr_endcopy - (caddr_t)&src->cr_startcopy)); + dest->cr_flags = src->cr_flags; crsetgroups(dest, src->cr_ngroups, src->cr_groups); uihold(dest->cr_uidinfo); uihold(dest->cr_ruidinfo); @@ -2210,7 +2220,7 @@ mtx_lock(&cr->cr_mtx); cr->cr_users--; if (cr->cr_users == 0) - KASSERT(cr->cr_ref > 0, ("%s: ref %d not > 0 on cred %p", + KASSERT(cr->cr_ref > 0, ("%s: ref " CR_REF_FORMAT " not > 0 on cred %p", __func__, cr->cr_ref, cr)); mtx_unlock(&cr->cr_mtx); crfree(cr); diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -59,10 +59,20 @@ * See "Credential management" comment in kern_prot.c for more information. */ #if defined(_KERNEL) || defined(_WANT_UCRED) + +#if defined(__ILP32__) +#define cr_ref_type int32_t +#elif defined(__LP64__) +#define cr_ref_type int64_t +#else +#error unknown data model +#endif + struct ucred { struct mtx cr_mtx; - u_int cr_ref; /* (c) reference count */ + cr_ref_type cr_ref; /* (c) reference count */ u_int cr_users; /* (c) proc + thread using this cred */ + u_int cr_flags; /* credential flags */ struct auditinfo_addr cr_audit; /* Audit properties. */ #define cr_startcopy cr_uid uid_t cr_uid; /* effective user id */ @@ -75,7 +85,6 @@ struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */ struct prison *cr_prison; /* jail(2) */ struct loginclass *cr_loginclass; /* login class */ - u_int cr_flags; /* credential flags */ void *cr_pspare2[2]; /* general use 2 */ #define cr_endcopy cr_label struct label *cr_label; /* MAC label */