Author: mjg
Date: Sat Aug  1 16:02:32 2020
New Revision: 363767
URL: https://svnweb.freebsd.org/changeset/base/363767

Log:
  cred: add more asserts for td_realucred == td_ucred

Modified:
  head/sys/kern/kern_prot.c
  head/sys/kern/kern_thread.c

Modified: head/sys/kern/kern_prot.c
==============================================================================
--- head/sys/kern/kern_prot.c   Sat Aug  1 14:58:43 2020        (r363766)
+++ head/sys/kern/kern_prot.c   Sat Aug  1 16:02:32 2020        (r363767)
@@ -1881,7 +1881,8 @@ crunuse(struct thread *td)
 {
        struct ucred *cr, *crold;
 
-       cr = td->td_ucred;
+       MPASS(td->td_realucred == td->td_ucred);
+       cr = td->td_realucred;
        mtx_lock(&cr->cr_mtx);
        cr->cr_ref += td->td_ucredref;
        td->td_ucredref = 0;
@@ -1897,6 +1898,7 @@ crunuse(struct thread *td)
                crold = NULL;
        }
        mtx_unlock(&cr->cr_mtx);
+       td->td_realucred = NULL;
        return (crold);
 }
 

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c Sat Aug  1 14:58:43 2020        (r363766)
+++ head/sys/kern/kern_thread.c Sat Aug  1 16:02:32 2020        (r363767)
@@ -543,6 +543,7 @@ thread_exit(void)
            (long)p->p_pid, td->td_name);
        SDT_PROBE0(proc, , , lwp__exit);
        KASSERT(TAILQ_EMPTY(&td->td_sigqueue.sq_list), ("signal pending"));
+       MPASS(td->td_realucred == td->td_ucred);
 
        /*
         * drop FPU & debug register state storage, or any other
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to