From nobody Fri Aug 25 15:34:16 2023 X-Original-To: dev-commits-src-main@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 4RXPBc5wkWz4rRYf; Fri, 25 Aug 2023 15:34:16 +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 4RXPBc5LT2z4jPn; Fri, 25 Aug 2023 15:34:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692977656; 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=OOKCPVwICrcnc8BUJa5tf9OozV26tEY0vQ1FHoA4mfM=; b=WpLrxrpiPFBoOTIFKdK3XL0WKJkOPKKzX+FBpaUZXVLONCh13qMDcCSXFt69Ris5qVl1eG WHnVsp3hMIJx8bk3iH5r9byu1c5/AJLHfltHdAF5mmji7wHl8wr1/u06YQWl0pz5nu2Ynl vdT7C+O5Tvik/kRLQt1QRURqtqVZsdADxRl2nSL81Hv4tDM7QjKPMZpVawcidVmZBDuM1R XjKz+X/HjxKYMW+Il2p+FYoc1Sa951JQBNddSpwXUc76exEueR/WFFrS8UJbHKwO4qNBhL DEp4XYGEcD2ONzrO5FUeoAqHvUtzEcpbnIPa1z4JZbMGOfQlnmtwwXZt30rQcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692977656; 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=OOKCPVwICrcnc8BUJa5tf9OozV26tEY0vQ1FHoA4mfM=; b=fMFVGJqP4OcJl1mlvvEPaVhdHz3976QuNNb+YPLLKoCEu3Tfg26ouwTpHA47N7MEs5H2gD Y4EE0JxXFJu8/JW1jUnMJA6MrFVJUwOWZ0Gw2kQSS4PatRRmKedJlzACJLPV8dCNAWlfRm mO2JCPoNKYyMR8I+rWDV/UEqiDrxbBl4WJkVDX1xl501QvGXVuHiNaOqwLa4Bl6b6SGWAu YpUXoe63LA8oiN7T3JXks6nt4Zo6FEVuyplP/vp+9mhSI0d+SIHiXrc7NSSulIy6AH8/jv 0I3Xk2D0EZ3/e4cQuhtmTWR2zVxf8Djrbc6gbzhtqAojdxQ6tTq1gFqejbi7Yw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692977656; a=rsa-sha256; cv=none; b=S+XvFupIhhTf+P55wM5psPKZf2jCMsGM84MuZV4lwEobM0ntcdNIItCDDSh7+J1dap4/ug /IS/+3vi4mKpijB5N00rOG33Jj6Sy7jXnQXIX23mWn5HnArXdhQBObznK0qHNZMXyP6HqC UJ292N8NL34ddicjXJzdsNaLFKuycsvU+WkUzad4+Rq3iUjvBiscYjpDTX0yQ1IltP3N1w pxdFI725+4gg3iY2wXifmSKUIqOA916m4dZeOJG7NkxCQvnUoFzzvLJzgrnhY8lVSzJfsV nOkKi9CpM1RpbzhBPQIoB09/T+Gdifn8XO4r40Ie9CDNgNy7yHFCovf0R+9PIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RXPBc4M9wz1DKG; Fri, 25 Aug 2023 15:34:16 +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 37PFYG0b000643; Fri, 25 Aug 2023 15:34:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37PFYGmv000639; Fri, 25 Aug 2023 15:34:16 GMT (envelope-from git) Date: Fri, 25 Aug 2023 15:34:16 GMT Message-Id: <202308251534.37PFYGmv000639@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: e40d16ad6ee9 - main - sctp: cleanup List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: e40d16ad6ee952f315356ef091fa282f28fac0d5 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=e40d16ad6ee952f315356ef091fa282f28fac0d5 commit e40d16ad6ee952f315356ef091fa282f28fac0d5 Author: Michael Tuexen AuthorDate: 2023-08-25 15:31:19 +0000 Commit: Michael Tuexen CommitDate: 2023-08-25 15:31:19 +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. MFC after: 1 week --- 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