From nobody Fri Sep 15 17:35:31 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RnLtq5TLrz4tPnV; Fri, 15 Sep 2023 17:35:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RnLtq50wHz3GyB; Fri, 15 Sep 2023 17:35:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694799331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Lnh7b7JM3Hk56K0sxWgT16S+4q8iuZMMTzvdJ0Nh0ZA=; b=Re5ivi2q2TnnJlRBoaKLG4J685s3FR4hsIyQXHbUqsFiKSJciaZa7qmL/hzaXa3E4DfQcR h5uyuG7U3LQS3z+bvAnMgJfbK99mjaODNd2aft6ByRBkGbsHrkrwIj9OxiI8a5r/X+3cIL 319Oq10N3p3hf7ohiLWFMjVWJ3UdsP5Yhd2fhhyw2hIF6bbPX1pT9AuxeRv+FFucvZ65sL vwLi0ZN4wNheqLogpF191HPzzqX+56sIPkOujBVPUISsB12hYN+VzEZVGh9k+wBv9faS5s /NxTqYY3LexDRB/QwHcFd0+E2rdjoTOqEjEj/wo+5glrByGLf7V5aCHumYTx+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694799331; a=rsa-sha256; cv=none; b=MSQH5nkU/uqHkIRcF8fgYfjwvAOKxcUHbr2wsX+Xx+Q6AAyQAVE3Kl1AvJX51aU0naWZgH TvXjrDShgjvD0ErMa2LMGbxOshZVHuwLW3H4Zg36KaKsfyxf/wa//d/L9+Mf1Iiu7HSSmY YuLqKnZ5pCdYfPCNqGe5bf6OdXDHJssLTRMCC+HiT5H1XS+tjTSL7tMkOrgyN/YKPs+K5o qIx2Bwgffw0j2oC3Sb8cVRSt8kVlLU3C8PFl6npCWT+3ZzP3D+d1CYGlOWFIR1SxEhixFr sMtpz54iFVexLv+NABtXy+DNcw2iCDa0dvkS7LCywydq8HcerbrbXyTiG+4iZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694799331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Lnh7b7JM3Hk56K0sxWgT16S+4q8iuZMMTzvdJ0Nh0ZA=; b=mdqBQrKkmGsLrdt/HcvpYo9XYNNDMoqQAFdEKUb0T38NEMw6ej0YQovOdcT6GUrGEJ+z3O xsVijEs5vu/nTmfPn0S3Gmehu5nyxIkT2qSC+ICK6DstVREejr0/C5Cu9FlMfZmxfzD3Cm yB1hrUkp5bBDYNP8wrIqlx9Fv/4XpwEfm/lTZ9+8QZ2MEfMm+rtOGoudY+s5xOq/2Fkfiv NeQ0eid3rMVn4yysx/lKVcGgPDQW1jzAv9fMS4qCvFiRojM0+Nni5b7nMdGNHKqFfViIuq kQ0Tzz74xVvuAb6BxeecDGwhIBvk5TIf8gbpkJF7tRQwEQnDiS/CP+bcjkUKRQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RnLtq466SzYlg; Fri, 15 Sep 2023 17:35:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38FHZVuQ039313; Fri, 15 Sep 2023 17:35:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38FHZVC7039311; Fri, 15 Sep 2023 17:35:31 GMT (envelope-from git) Date: Fri, 15 Sep 2023 17:35:31 GMT Message-Id: <202309151735.38FHZVC7039311@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 6cf1d4a323d7 - stable/14 - sctp: cleanup List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 6cf1d4a323d7cd5d224950dcf494a0a13d453884 Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=6cf1d4a323d7cd5d224950dcf494a0a13d453884 commit 6cf1d4a323d7cd5d224950dcf494a0a13d453884 Author: Michael Tuexen AuthorDate: 2023-08-25 15:31:19 +0000 Commit: Michael Tuexen CommitDate: 2023-09-15 17:33:35 +0000 sctp: cleanup In particular, don't use a socket level flag, use the inp level one. After adding appropriate locking, this will close a race condition. --- sys/netinet/sctputil.c | 60 +++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 2f021c22165e..381f67f40b99 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -4054,14 +4054,14 @@ void sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, uint32_t error, void *data, int so_locked) { - if ((stcb == NULL) || - (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || - (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || - (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { - /* If the socket is gone we are out of here */ - return; - } - if (stcb->sctp_socket->so_rcv.sb_state & SBS_CANTRCVMORE) { + struct sctp_inpcb *inp; + struct sctp_nets *net; + + KASSERT(stcb != NULL, ("stcb == NULL")); + SCTP_TCB_LOCK_ASSERT(stcb); + + inp = stcb->sctp_ep; + if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) { return; } if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) || @@ -4073,6 +4073,12 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, return; } } + if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ)) { + return; + } + switch (notification) { case SCTP_NOTIFY_ASSOC_UP: if (stcb->asoc.assoc_up_sent == 0) { @@ -4091,32 +4097,20 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, sctp_notify_assoc_change(SCTP_SHUTDOWN_COMP, stcb, error, NULL, false, false, so_locked); break; case SCTP_NOTIFY_INTERFACE_DOWN: - { - struct sctp_nets *net; - - net = (struct sctp_nets *)data; - sctp_notify_peer_addr_change(stcb, SCTP_ADDR_UNREACHABLE, - (struct sockaddr *)&net->ro._l_addr, error, so_locked); - break; - } + net = (struct sctp_nets *)data; + sctp_notify_peer_addr_change(stcb, SCTP_ADDR_UNREACHABLE, + &net->ro._l_addr.sa, error, so_locked); + break; case SCTP_NOTIFY_INTERFACE_UP: - { - struct sctp_nets *net; - - net = (struct sctp_nets *)data; - sctp_notify_peer_addr_change(stcb, SCTP_ADDR_AVAILABLE, - (struct sockaddr *)&net->ro._l_addr, error, so_locked); - break; - } + net = (struct sctp_nets *)data; + sctp_notify_peer_addr_change(stcb, SCTP_ADDR_AVAILABLE, + &net->ro._l_addr.sa, error, so_locked); + break; case SCTP_NOTIFY_INTERFACE_CONFIRMED: - { - struct sctp_nets *net; - - net = (struct sctp_nets *)data; - sctp_notify_peer_addr_change(stcb, SCTP_ADDR_CONFIRMED, - (struct sockaddr *)&net->ro._l_addr, error, so_locked); - break; - } + net = (struct sctp_nets *)data; + sctp_notify_peer_addr_change(stcb, SCTP_ADDR_CONFIRMED, + &net->ro._l_addr.sa, error, so_locked); + break; case SCTP_NOTIFY_SPECIAL_SP_FAIL: sctp_notify_send_failed2(stcb, error, (struct sctp_stream_queue_pending *)data, so_locked); @@ -4227,7 +4221,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, SCTPDBG(SCTP_DEBUG_UTIL1, "%s: unknown notification %xh (%u)\n", __func__, notification, notification); break; - } /* end switch */ + } } void