From nobody Wed Apr 27 14:08:51 2022 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 8B91C1999CAF; Wed, 27 Apr 2022 14:08:51 +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 4KpLFv3Y3gz3J5t; Wed, 27 Apr 2022 14:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651068531; 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=VKI9E7whQmVZxCUUuEk/kx6Q7J82o3C4C0l5WGSMxKw=; b=jqmwwnkE4lwzlk2/jtILMumQiCxoEq2RRImhd2yLIipTdI+nVlm1XWy3uKTjrlj7BSDSDe qFEqp8j+adL3lCqU6NhYz5Fbaa2lSGIxma5B6ksSySiyYsCbqJNKnr+y79yB/MBGM7TY9/ XZqkLTML6RIsR9NHb2CiZ6+KnLaPMA4Rsj2JFgxmkIOX8/yPZSn85xaUhuHIXUwvJiEJEl K7jXSD6d0WU+UO9jY7w3knSLln6zNLKjxQqcSZmhRqyGVlmCntixM/KuSjst2iB32jTevB FIUcdCn2j/dtjS9KwbVyro7rlro460aeHWyQloP3JQn7cxaqsHxL6OK38hKa0g== 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 59860253EC; Wed, 27 Apr 2022 14:08:51 +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 23RE8pot014051; Wed, 27 Apr 2022 14:08:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RE8pi7014050; Wed, 27 Apr 2022 14:08:51 GMT (envelope-from git) Date: Wed, 27 Apr 2022 14:08:51 GMT Message-Id: <202204271408.23RE8pi7014050@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: 490a0f77de77 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 490a0f77de77321859eeeecc807f9cc7bb41dbcc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651068531; 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=VKI9E7whQmVZxCUUuEk/kx6Q7J82o3C4C0l5WGSMxKw=; b=akbTvw/TO2FLc0j6KizALcFMa3bjDjJYX3+p02wrMJz1jiQ2Dc8QZq8veW1FrVPT5ttW1S 9vOLUdOdZ/wZKQ3MHevwqvgip4ABGG5lCLScl/KXyDAADNQrJr4oi6oNCb0T5sleEsrWmJ +UIWNolxCWSWlq769+jfPOucVKdkOS4ALZRnQLajGEckPSW8sUS1ZAnIzBmauqUGGpEvtO Busc5GWTWkghsJyzxf0Pn4DVQEDEWh6KqrvusV/8peepWg7FBvoiqxhMuBPoaxOxw+uqdd D4nXyTZJjyjMQTiJFzZ4QqeaqnzvO6Y4K5O2Ns5C8MHDBZhemB8o4ZuCDcI2Tw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651068531; a=rsa-sha256; cv=none; b=BwnmOz9LMIgYG3HPldskfZ2WGTB7HWYHAOK5ZpWJpqJZmmHtu+4ig0lm8uRPU/9b16O4zk /v6s5VPt+KcLgABi4yDeZwKK31x50JLynwVRGHw0Cx04Xg8AiBDq+FueLDaGZJUJxOtb90 i2g3o94/lSe68u7uW93rUXxq7TOyZWPSBRAJ19i/YVP3t64ZYB9sh6JsBILuBDOqqteHzb ohDRxTa1d2a82DIxG6EyhJ9TbWk6tQqsrBj9Ur3zKbX1r2+T8CcB9Jdre1oAqaDb6hyHNL WZ72clZpfSh0voVMHvyZncLsMWZ4UzWtH13DIGBky9ISjXCMMy721idY+KG91Q== 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=490a0f77de77321859eeeecc807f9cc7bb41dbcc commit 490a0f77de77321859eeeecc807f9cc7bb41dbcc Author: Michael Tuexen AuthorDate: 2022-04-27 14:07:31 +0000 Commit: Michael Tuexen CommitDate: 2022-04-27 14:07:31 +0000 sctp: improve locking While there, do some cleanup. Reported by: syzbot+f475e054c454310bc26d@syzkaller.appspotmail.com MFC after: 3 day --- 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 cff19a48a3c0..8451ed5e2007 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