From nobody Wed Sep 27 12:52:25 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 4Rwc2f18kQz4vQXf; Wed, 27 Sep 2023 12:52:26 +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 4Rwc2f0hjFz4T8j; Wed, 27 Sep 2023 12:52:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695819146; 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=wQiH4U0E2XtifZiNvfoXsvWobMWvy+bOSWE7p3x82P4=; b=w7e9pFcq8sOhLMs8ETBnht0k0NhDCLZBF7jmfmKSlcTLDjCtzNvB7n6X1J47MCmzD22ffX xU9/z29HiKNF2LdStOeoNbxJpxRMemF5+gPV4LCyg/JZ2MuGjhP4Hfc1GSmM8sDi9rz4do CZs41Xrcaw1y6i6O96XD7eS4qTWyzuFyA5Ge4+8WeQcCORQxIQr0arkyZJngBqW0XtYNJh oZ1uSL3WaeIwub2hxMLAT3ucT6LVKCNKSnAIz73IfThsjoZKrNGo2yvfNLOTlibX+1Ox1L tEiBrUIAptzZLqxjn+jyNnlJb6NtyFhAiLAXXpWmugzPFtFTXIs65PYo0qQxIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695819146; a=rsa-sha256; cv=none; b=ZLe/WceGBGpbdl8n6F+dKzN7+I6XuSnaNkVjwoyAQ8ELDP6QitHpRkJZZIyZ1my8hwAe1u yjTMuXuAI2oN6m4S3Kp68omft6J/pvZ39dWBp2CE5TViXLKRUPIe+P5JVkK/e8GQuHu+sv YF13zqcWFTVslBBrmQ8FJr9FUI3ggvXnMVU8AnXhfDDqnlNqb8k01dqW633wdbaG+lY5wU Y/Xuzn5eMi7DR+Bdwnb/jG5oS52sFdmNh731XtX3APPJ+4V7rYkdRl5tEZfifuUItws3/x X+nnASjs4wTLG3LlrVQws868+IjjZlWCwNjCNvWEw8OrLIbaD8+ESVLr6D/Myg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695819146; 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=wQiH4U0E2XtifZiNvfoXsvWobMWvy+bOSWE7p3x82P4=; b=qaP2S31Ctl+pb1J3P8CnAUq9+uz4oFXNcHrKwXZZFI91LUQfZEHf0x3WqhKOKA6zjiwaoq QlTqL8fuvmThTa6vE/B6iATXCVyDW953k6GXiH3sQ63rtaxYLiW/NUtZNkGSNVWDvistCi 0fnUkwn+xRzxEjs6zOc+E+bUNa789+7libd3CuDD7BZM/+WDsmY4fiM+Ba7CByYyTNpOgl ptx4KVX9FNU0CNZa6W+4NLov4CsbyLjpyu+P1/w28Y4lgLozXEsyfuzx5m+nyDXDYb6dtN fPQBIPo0Hw6+awRFwTtEtyiZY2hdsUuv4XesPb2b3kNB2CRwG/MffI1qrhKWcA== 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 4Rwc2d6swTzgSb; Wed, 27 Sep 2023 12:52:25 +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 38RCqPe1023096; Wed, 27 Sep 2023 12:52:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38RCqPkK023093; Wed, 27 Sep 2023 12:52:25 GMT (envelope-from git) Date: Wed, 27 Sep 2023 12:52:25 GMT Message-Id: <202309271252.38RCqPkK023093@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 862d2d514cb7 - stable/13 - sockets: re-check socket state after call to pr_rcvd() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 862d2d514cb782353bce1af99d670db08b1e6c3c Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=862d2d514cb782353bce1af99d670db08b1e6c3c commit 862d2d514cb782353bce1af99d670db08b1e6c3c Author: Greg Becker AuthorDate: 2023-09-09 23:38:24 +0000 Commit: Mark Johnston CommitDate: 2023-09-27 12:33:08 +0000 sockets: re-check socket state after call to pr_rcvd() Socket state may have changed after dropping the receive buffer lock in order to call pr_rcvd(). If the buffer is empty, re-check the state after reaquiring the lock and skip calling sbwait() if the socket is in error or the peer has closed. PR: 212716 Reviewed by: markj, glebius MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41783 (cherry picked from commit f44102411e1b16363e91a074c9c403069c550e4d) --- sys/kern/uipc_socket.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a4623329e686..e5997e439964 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2326,6 +2326,10 @@ dontblock: VNET_SO_ASSERT(so); (*pr->pr_usrreqs->pru_rcvd)(so, flags); SOCKBUF_LOCK(&so->so_rcv); + if (__predict_false(so->so_rcv.sb_mb == NULL && + (so->so_error || so->so_rerror || + so->so_rcv.sb_state & SBS_CANTRCVMORE))) + break; } SBLASTRECORDCHK(&so->so_rcv); SBLASTMBUFCHK(&so->so_rcv);