From nobody Mon Jun 27 17:06:54 2022 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 9030487DD3B; Mon, 27 Jun 2022 17:06:54 +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 4LWvKB3g0cz4tFN; Mon, 27 Jun 2022 17:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656349614; 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=5vATW/YmJLlawqa5BK76WH207YkOwHuctc9K4k/cr0g=; b=Ku3d20Q90vqZOtVLBrpyai0oXEN0NZxKUPkGVOFE5akQtS5r5I39SLLzSofR0Fky6NKxpm hSzvdxAhM+d239RJQaJlYTdxQ2k8AjskJjDaIzNT6EtDQ3ETcheK0y5+Rxgg1E1NWdKdRU l5/TXXLoZ0l6p1ME12Olbu3TbpJx7FDTQ7KW/OzSUI2CKHH7FV0CoLYcf3oHU4sTOZpyBG 0ErRrNpjHXN1MGhVzkJb54GjtgU9NY7g/A+ulCDpYvpVfSojNwohjU+s7Jf3PxoOZYo8Z3 GxY8q6vFKd8qGp8jtZHobKOFoINZ5Vc2pZA6rJKzxSkwLw59U4wmdsqQZZSrVg== 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 5E3D744DF; Mon, 27 Jun 2022 17:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25RH6sPn015535; Mon, 27 Jun 2022 17:06:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25RH6sv6015534; Mon, 27 Jun 2022 17:06:54 GMT (envelope-from git) Date: Mon, 27 Jun 2022 17:06:54 GMT Message-Id: <202206271706.25RH6sv6015534@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: 121ecca0d82b - main - sctp: add KASSERTs to ensure correct handling of listeners 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: 121ecca0d82b4a5ccee1a8bb01e50b026a22bb3f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656349614; 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=5vATW/YmJLlawqa5BK76WH207YkOwHuctc9K4k/cr0g=; b=aloKJX0B6GMwFs3AidKXOcDR8JNAkeLmK77vvR1lSrtAX0i6SR4EcK8xw8ArYJmUfcUcGo XAU0bHjdkFWaS08kTncdmJDE1dCoW+II8b8TqgmXcl0PRIL+C6AuHHWUrLX4krqX5rWrhh hZ71snEFEB4z5xd6lovUBf2ltjTdWiFpXcz5xIWoLGWsH9wrN4gvsmqDzUd6Jyn/+Hifnm mtOz0hLWXdiqasQFMMlG7pmFmKa4OeyivWBZa7XbtI85ARyqMFfkumZfucB25tnIqE1ajc 2N3AAbHS8hTss+83QEqRqWlPFuZLzThQLKh59aacU8BUwgPrnYkcZBfry7xAmg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656349614; a=rsa-sha256; cv=none; b=XfIcNYHxqyPZNAxDd7/y4kUDglTzU45z/byBixruAnko8dqkLFQUBXpXFsknzjYeRXCN/b BR4C+Pl0qlomzh2kWprKAp6qV5zZmm8ShwlxCND0HQSwe8tfBb4JdvcKxbuNeXm36QQLvW VFWpjU4Ol246BCiGxHv35bH4vlGkcVBa/XVXttRA86/HI7AYcGdE/qhbwguwFtXVBfbPF7 GMCrQXTViWIo0tZ9kc6HpF7cnK1iQAak3upcIOndpjaPTHgk4r8qVcI1pg2SxvRvJnQwEp rdw4pXVO2BlIOT5BDP5WpT8qNp/XMxKnnZRkKRKHGLuOxFteGfyfh+zJYEdH6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=121ecca0d82b4a5ccee1a8bb01e50b026a22bb3f commit 121ecca0d82b4a5ccee1a8bb01e50b026a22bb3f Author: Michael Tuexen AuthorDate: 2022-06-27 17:04:45 +0000 Commit: Michael Tuexen CommitDate: 2022-06-27 17:04:45 +0000 sctp: add KASSERTs to ensure correct handling of listeners This was suggested by markj@. MFC after: 3 days --- sys/netinet/sctp_usrreq.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 90c019ef2afd..285fbcfbf512 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -454,13 +454,10 @@ sctp_abort(struct socket *so) sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); SOCK_LOCK(so); + KASSERT(!SOLISTENING(so), + ("sctp_abort: called on listening socket %p", so)); SCTP_SB_CLEAR(so->so_snd); - /* - * same for the rcv ones, they are only here for the - * accounting/select. - */ SCTP_SB_CLEAR(so->so_rcv); - /* Now null out the reference, we are completely detached. */ so->so_pcb = NULL; SOCK_UNLOCK(so); @@ -842,14 +839,22 @@ sctp_flush(struct socket *so, int how) inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_CANT_READ; SCTP_INP_READ_UNLOCK(inp); SCTP_INP_WUNLOCK(inp); + SOCK_LOCK(so); + KASSERT(!SOLISTENING(so), + ("sctp_flush: called on listening socket %p", so)); SCTP_SB_CLEAR(so->so_rcv); + SOCK_UNLOCK(so); } if ((how == PRU_FLUSH_WR) || (how == PRU_FLUSH_RDWR)) { /* * First make sure the sb will be happy, we don't use these * except maybe the count */ + SOCK_LOCK(so); + KASSERT(!SOLISTENING(so), + ("sctp_flush: called on listening socket %p", so)); SCTP_SB_CLEAR(so->so_snd); + SOCK_UNLOCK(so); } return (0); }