The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7326e8589cc21431d62f25802eac7c5dd6f74122

commit 7326e8589cc21431d62f25802eac7c5dd6f74122
Author:     Mark Johnston <[email protected]>
AuthorDate: 2021-08-28 19:50:44 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2021-08-28 19:50:44 +0000

    fsetown: Avoid process group lock recursion
    
    Restore the pre-1d874ba4f8ba behaviour of disassociating the current
    SIGIO recipient before looking up the specified process or process
    group.  This avoids a lock recursion in the scenario where a process
    group is configured to receive SIGIO for an fd when it has already been
    so configured.
    
    Reported by:    pho
    Tested by:      pho
    Reviewed by:    kib
    MFC after:      3 days
---
 sys/kern/kern_descrip.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index f78e999ab3b5..ed7fe83cf02f 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1158,14 +1158,12 @@ fsetown(pid_t pgid, struct sigio **sigiop)
        sigio->sio_ucred = crhold(curthread->td_ucred);
        sigio->sio_myref = sigiop;
 
-       osigio = NULL;
        ret = 0;
        if (pgid > 0) {
                ret = pget(pgid, PGET_NOTWEXIT | PGET_NOTID | PGET_HOLD, &proc);
                SIGIO_LOCK();
+               osigio = funsetown_locked(*sigiop);
                if (ret == 0) {
-                       osigio = funsetown_locked(*sigiop);
-
                        PROC_LOCK(proc);
                        _PRELE(proc);
                        if ((proc->p_flag & P_WEXIT) != 0) {
@@ -1191,12 +1189,11 @@ fsetown(pid_t pgid, struct sigio **sigiop)
        } else /* if (pgid < 0) */ {
                sx_slock(&proctree_lock);
                SIGIO_LOCK();
+               osigio = funsetown_locked(*sigiop);
                pgrp = pgfind(-pgid);
                if (pgrp == NULL) {
                        ret = ESRCH;
                } else {
-                       osigio = funsetown_locked(*sigiop);
-
                        if (pgrp->pg_session != curthread->td_proc->p_session) {
                                /*
                                 * Policy - Don't allow a process to FSETOWN a
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to