Date: Mon, 22 Aug 2016 01:45:29 +0000 (UTC) From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304579 - head/sys/netinet Message-ID: <201608220145.u7M1jTws079803@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tuexen Date: Mon Aug 22 01:45:29 2016 New Revision: 304579 URL: https://svnweb.freebsd.org/changeset/base/304579 Log: Improve the locking when sending user messages. First, keep a ref count on the stcb after looking it up, as done in the other lookup cases. Second, before looking again at sp, ensure that it is not freed, because the assoc is about to be freed. MFC after: 3 days Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Mon Aug 22 01:43:47 2016 (r304578) +++ head/sys/netinet/sctp_output.c Mon Aug 22 01:45:29 2016 (r304579) @@ -12639,7 +12639,10 @@ sctp_lower_sosend(struct socket *so, } SCTP_INP_RUNLOCK(inp); } else if (sinfo_assoc_id) { - stcb = sctp_findassociation_ep_asocid(inp, sinfo_assoc_id, 0); + stcb = sctp_findassociation_ep_asocid(inp, sinfo_assoc_id, 1); + if (stcb != NULL) { + hold_tcblock = 1; + } } else if (addr) { /*- * Since we did not use findep we must @@ -13404,6 +13407,10 @@ skip_preblock: } } SCTP_TCB_SEND_LOCK(stcb); + if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + SCTP_TCB_SEND_UNLOCK(stcb); + goto out_unlocked; + } if (sp) { if (sp->msg_is_complete == 0) { strm->last_msg_incomplete = 1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608220145.u7M1jTws079803>