Author: tuexen
Date: Sun May 10 22:54:30 2020
New Revision: 360885
URL: https://svnweb.freebsd.org/changeset/base/360885

Log:
  Ensure that the SCTP iterator runs with an stcb and inp, which belong to
  each other.
  
  Reported by:  syzbot+82d39d14f2f765e38...@syzkaller.appspotmail.com
  MFC after:    3 days

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==============================================================================
--- head/sys/netinet/sctputil.c Sun May 10 21:37:39 2020        (r360884)
+++ head/sys/netinet/sctputil.c Sun May 10 22:54:30 2020        (r360885)
@@ -1489,6 +1489,7 @@ select_a_new_ep:
                }
                tinp = it->inp;
                it->inp = LIST_NEXT(it->inp, sctp_list);
+               it->stcb = NULL;
                SCTP_INP_RUNLOCK(tinp);
                if (it->inp == NULL) {
                        goto done_with_iterator;
@@ -1558,6 +1559,9 @@ select_a_new_ep:
                        atomic_add_int(&it->stcb->asoc.refcnt, -1);
                        iteration_count = 0;
                }
+               KASSERT(it->inp == it->stcb->sctp_ep,
+                       ("%s: stcb %p does not belong to inp %p, but inp %p",
+                        __func__, it->stcb, it->inp, it->stcb->sctp_ep));
 
                /* run function on this one */
                (*it->function_assoc) (it->inp, it->stcb, it->pointer, it->val);
@@ -1590,6 +1594,7 @@ no_stcb:
        } else {
                it->inp = LIST_NEXT(it->inp, sctp_list);
        }
+       it->stcb = NULL;
        if (it->inp == NULL) {
                goto done_with_iterator;
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to