From nobody Wed Feb 01 22:46:37 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 4P6cV53Q9Kz3cFSr; Wed, 1 Feb 2023 22:46:37 +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 4P6cV52rDvz4Nnd; Wed, 1 Feb 2023 22:46:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675291597; 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=Hlc0udmiydAqCo3BGGVSKmvL9KDuhN1qavVkn17orhg=; b=qp7s+FuTHcWBFOMnD7yqdRmBWWF16SYY/Byy5Yywk2LQ/58uXNMldoZ0Pz01aP4ZdiF/dh d894WAH4XQ4b5lN9VPybTkYFvGzvbck9qCoD19fdtloc+k2OBQXpoQgQ09svh9Lz/sAvbj CVcO4K3iVxbj0xT7ir/SjZiyX0H+iz6AIND0Wcw0ShWOKfUMvU1o99WAIAxcxrQ3NS0vvK yjnwexvmZ7L6oFo7Se7GorYxpy0U2jPdQ/53jvH+E/PWXAVJqtLfAZDvv8SKUSu6r3afWY 0AM5Pv4AP0EFpeYTAuiBQ7ciNliinGAWs85zB8C2fSD/3nuVjgrDaMERkec8fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675291597; 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=Hlc0udmiydAqCo3BGGVSKmvL9KDuhN1qavVkn17orhg=; b=YWlX4zOYVIuhIK6HVexoZerA+mJwdxeN5e9efTtZFn3PW+FuQIbQdVWTN8aOpEbZCx+idY Z+XhIVcb4FJ1FJdPbuTrqQgUMJqa+Dr2EQziIr7wsWoe8FuLFaLLVvOCyZVYHvfTMnAkWI KUqwfxjSSVHMjnFAeIhxjmryI/DPUJANZKqYbyVybQc1rJ2dDM3GN8+RoyYv5ZJRfwwT66 bK/QcrU08APw9A1oTG7nzkl0uIhe6Sst6HqNQzmgvUbVON1ld2BlCsVWURb2MGAQGgoMnw 3bLF/I/JynV6mfAhvkzGsvvl8KqCT/3QWl59mObAXTP2V1n/B8/5s7b+/m6D8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675291597; a=rsa-sha256; cv=none; b=u2ONG+YFYHlaQ78g2z/ZdAzPi0F0DeF1KMoItOGSWDvMwPUhREnIfMBrQPkUGgZ3AfrBpj 5DQHz2cWz+msbEGtkMUDrbXRMqZgdFxp4EG6/PmhuRDxZcQfU/NHPfLH/T32Ku6zRv/nxG A31CEM0DSQaNSWORbMUJ/RQ/VqXU97SaMIefAbQdtsr55rTSuTNanhNoJV8/S4M5so74xL WTdgxTRptu3M8IF4dYb+9esUtEf4aQ1330QqVOELU1EE2PorWxz4i8X0cKNGJy6QFd6/+U mP0HAfIEVhplSwI/mfzKKPp/QUGyha59tN0vAG5K5HJvlgVA3ur8kpLGl0RRWw== 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 4P6cV51vj1zWTD; Wed, 1 Feb 2023 22:46:37 +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 311MkbUH002810; Wed, 1 Feb 2023 22:46:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 311MkbOE002809; Wed, 1 Feb 2023 22:46:37 GMT (envelope-from git) Date: Wed, 1 Feb 2023 22:46:37 GMT Message-Id: <202302012246.311MkbOE002809@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: 8c5796ba8e32 - stable/13 - sctp: improve locking 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/13 X-Git-Reftype: branch X-Git-Commit: 8c5796ba8e329c9e202e0e914e8e98fed4cd2248 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=8c5796ba8e329c9e202e0e914e8e98fed4cd2248 commit 8c5796ba8e329c9e202e0e914e8e98fed4cd2248 Author: Michael Tuexen AuthorDate: 2022-04-27 14:07:31 +0000 Commit: Michael Tuexen CommitDate: 2023-02-01 22:46:14 +0000 sctp: improve locking While there, do some cleanup. Reported by: syzbot+f475e054c454310bc26d@syzkaller.appspotmail.com (cherry picked from commit 490a0f77de77321859eeeecc807f9cc7bb41dbcc) --- sys/netinet/sctputil.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 9405814d3d13..dad937f15172 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -4870,8 +4870,9 @@ sctp_add_to_readq(struct sctp_inpcb *inp, #endif return; } - if (inp_read_lock_held == 0) + if (inp_read_lock_held == SCTP_READ_LOCK_NOT_HELD) { SCTP_INP_READ_LOCK(inp); + } if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ) { if (!control->on_strm_q) { sctp_free_remote_addr(control->whoFrom); @@ -4881,8 +4882,9 @@ sctp_add_to_readq(struct sctp_inpcb *inp, } sctp_free_a_readq(stcb, control); } - if (inp_read_lock_held == 0) + if (inp_read_lock_held == SCTP_READ_LOCK_NOT_HELD) { SCTP_INP_READ_UNLOCK(inp); + } return; } if (!(control->spec_flags & M_NOTIFICATION)) { @@ -4894,7 +4896,7 @@ sctp_add_to_readq(struct sctp_inpcb *inp, m = control->data; control->held_length = 0; control->length = 0; - while (m) { + while (m != NULL) { if (SCTP_BUF_LEN(m) == 0) { /* Skip mbufs with NO length */ if (prev == NULL) { @@ -4938,11 +4940,12 @@ sctp_add_to_readq(struct sctp_inpcb *inp, } TAILQ_INSERT_TAIL(&inp->read_queue, control, next); control->on_read_q = 1; - if (inp_read_lock_held == 0) - SCTP_INP_READ_UNLOCK(inp); - if (inp && inp->sctp_socket) { + if ((inp != NULL) && (inp->sctp_socket != NULL)) { sctp_wakeup_the_read_socket(inp, stcb, so_locked); } + if (inp_read_lock_held == SCTP_READ_LOCK_NOT_HELD) { + SCTP_INP_READ_UNLOCK(inp); + } } /*************HOLD THIS COMMENT FOR PATCH FILE OF