From nobody Thu Aug 24 13:57:17 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 4RWl593R6jz4rCHG; Thu, 24 Aug 2023 13:57:17 +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 4RWl592k1tz4F6l; Thu, 24 Aug 2023 13:57:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692885437; 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=x6ifxJjvBXlUulYZt8LjbGsKwIA1abls5/9KGFTGtew=; b=UYXwBwtE32j1rkerJ+R19T0kIjhLugsM8XY1jPQLu0Ex6T3vtBZvzG3RprFz3EsSyTjSX4 HpkYN23FlKk+nTrJj6DstcTnJEXenZgQUlZWoBaGZjBFdvh9lQ6cHcwqKlWvfGQh+TJ2Uu kSZcvJ/RVUxc18VjGK6Z7VhNSIPa5AfrW0hWc1FZaAfgQ+VR+4h6XsnwzBFqUAVJnCqDeX 0ohvS3SLfGykJTNavbvGrts3LpffiLdnzfZ+P8C8FSungOvDebDb6SJnHQUtq+sD2MCSeP UKmraE9+yBEP72NsbROQ5vmPWJxWahR8eDEuFtWqbDYbEcNccZgIourW9+NXVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692885437; 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=x6ifxJjvBXlUulYZt8LjbGsKwIA1abls5/9KGFTGtew=; b=Q5w15EcY6ybhs0lM8U6HOw412BCK24EDBZpUkSm7BE1pg0F1vfgG8lbaSukN4F+sPjKqbT K16ynAbjvQS+oEXz/gFQ2z0hKF40ndBQWqK3XaQqxVxUgEfYzV5OhPo/g/d5ZkuWcYbFBA qps5YR7rwaoNOJbKz3nS0qNkQ1OBmn8Q77KeBZm+thLc6rTBMAsZYR2X1D+EE4iMIzZuda L/JEpSOBR/58EMkNweUkZOjJ+mHdWbCvFG8ssCh0eOFb/+nagWTCOg4FVLA1+Z0yXmHehz 7kzFrB7s4tynD8zTilAhDl6Q72S+wA2AZHTjsHrVHvbTbuwrSbK+IenQ62tmKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692885437; a=rsa-sha256; cv=none; b=CwF1SaqBWzFiVcF0w9mZXLPGcd5K0zm2FBY1jQaMcC5udLd503Cfm5RZJJwTvO75y85yRA dGCagH1Cdd0+n05vPQ42kbzUiFUquEh+TPQKTiK5AvCheAixi25RXi+CCL6JeU0O/khrCd N6b9GGzbxNU1hLyGsq6LqGeEWaStDbOvEVOBUddKrpAKGDFY8sfpMRbkcsPbhNZ5M1pxKI QGR4n8ePWdTjPFi2agw2it/ue4cyBxrYfligUqzUktLJXexxq+/uVz5JcjfdPHw/R7RY2A 9YfZSPnXOwjWmL3HdMIcgPZpmvymaKPDQ/ZQwSvc2tkvpWDd96nlN+EwlNibMQ== 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 4RWl591T3PzTnG; Thu, 24 Aug 2023 13:57:17 +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 37ODvH9N045368; Thu, 24 Aug 2023 13:57:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37ODvHPc045365; Thu, 24 Aug 2023 13:57:17 GMT (envelope-from git) Date: Thu, 24 Aug 2023 13:57:17 GMT Message-Id: <202308241357.37ODvHPc045365@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: 847fa61fad5e - main - sctp: improve handling of socket shutdown for reading 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: 847fa61fad5ef118dc0591d876bf9449200aa818 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=847fa61fad5ef118dc0591d876bf9449200aa818 commit 847fa61fad5ef118dc0591d876bf9449200aa818 Author: Michael Tuexen AuthorDate: 2023-08-24 13:52:55 +0000 Commit: Michael Tuexen CommitDate: 2023-08-24 13:52:55 +0000 sctp: improve handling of socket shutdown for reading If a socket is marked as cannot read anymore, drop chunks which should be added to a control element in the receive queue. This is consistent with dropping control elements instead of adding them in the same situation. Reported by: syzbot+291f6581cecb77097b16@syzkaller.appspotmail.com MFC after: 1 week --- sys/netinet/sctp_indata.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index f7f0e3fdfe7f..c195cce96f39 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -1290,14 +1290,17 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control, * control and free up the chunk resources. */ uint32_t added = 0; - int i_locked = 0; + bool i_locked = false; - if (control->on_read_q && (hold_rlock == 0)) { - /* - * Its being pd-api'd so we must do some locks. - */ - SCTP_INP_READ_LOCK(stcb->sctp_ep); - i_locked = 1; + if (control->on_read_q) { + if (hold_rlock == 0) { + /* Its being pd-api'd so we must do some locks. */ + SCTP_INP_READ_LOCK(stcb->sctp_ep); + i_locked = true; + } + if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ) { + goto out; + } } if (control->data == NULL) { control->data = chk->data; @@ -1346,6 +1349,7 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control, control->end_added = 1; control->last_frag_seen = 1; } +out: if (i_locked) { SCTP_INP_READ_UNLOCK(stcb->sctp_ep); }