From nobody Wed Sep 27 12:53:18 2023 X-Original-To: dev-commits-src-branches@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 4Rwc3f57BNz4vQvL; Wed, 27 Sep 2023 12:53:18 +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 4Rwc3f2L7Nz4Vh4; Wed, 27 Sep 2023 12:53:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695819198; 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=ticLF6CBSkkh3ykt2zgJBJTFFUHxb5eBoWlUAnH6FkI=; b=YiVarW6ARw6Uqvpt52hXf9p52fXo1UHHdSqrRnkhT6IJSZDjHQaS325lRwZqQs93Qf0BZ6 SpTgguM8zR1jvVomipab9csD7r+tTyYiIctzk4mOQ/7jgd7GghhaJWx+ofBHF+bMYzAS77 Zb8ZGH0tUvJnUOkX6FoefR8JgdiGF8Mf+0vOg9ZIJOHdRDgAehesl3iOccLsPcva4Y2yZo qRj36TfVD61XGJ7HXWgRSRS+/oxdkiJ0kueMBPMcIIthU8QAqu5+sKclYc3ytfGmjOvfMF 66j6B7UN3QHbjoeB/bRRQsLNiGmj2fje4AuJMCEESibnmzmrdbuTtr3hU5XE8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695819198; a=rsa-sha256; cv=none; b=lijhCynmGVKLGyh3olwYkRPqHM6fQWrZiPpEZAXjmWg8nlY3IxKmGF23C6tuyebL39+qJu f+Rn2xl3ooZdu4Cm9RMyLNpf5PrCufBElmm8qpOd5R9f25zYkGZTgjbmqLjJaVuxH++h4H dpNypemk0M1Om5ogd+AP3kJC2hVieUQakbXJ3uCmDmcouoeVMNsZ3fb369K2As+6W3otPe Cx9y/GbGSzOExA7c5hTooPPiOip1qCBKMTeSkZZ8UjUnuFqsNtB5I0H2ksSo0HLDdlDtpa P/UQ0nVUKjX6KluaPWH2g7plz+pKvKQd4Ih+H9INRbkzcnO2g8lQ9iS4TPsfnQ== 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=1695819198; 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=ticLF6CBSkkh3ykt2zgJBJTFFUHxb5eBoWlUAnH6FkI=; b=IidAMNqcXD6uYBIMMkl93vQtgkRZRIVkCZM62zklqYQVc0jpZ3hyD9N8pLDr61oc2kEPp2 pj3J3XUfjWHdp3BhnbvZGKF5lNEF4BjgSTE+xpgRprMFMtNBIOk5zcQApq6LaqL7FoDArO z2+m/57PyLLTARlMEIUPhusPy7dxy5LH7tUZKvhMqbEaLcinNbJFXuTjwVZFBi8v1XfT1n i1DlM9WXukr1JBYA9cGQyEhjle9PqAiN/kgDrY82QJ4GKQBekTkRKQTbabvhRsYNcn7HZs V6Kg8BGXJSzq00LCK2uH9vcddAzYk4QjiFSDnAbv70jH6mHru9GVYvptsWAhrA== 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 4Rwc3f1RdzzgQs; Wed, 27 Sep 2023 12:53:18 +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 38RCrIx8024550; Wed, 27 Sep 2023 12:53:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38RCrIW7024547; Wed, 27 Sep 2023 12:53:18 GMT (envelope-from git) Date: Wed, 27 Sep 2023 12:53:18 GMT Message-Id: <202309271253.38RCrIW7024547@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: caaea4557738 - stable/14 - sockets: re-check socket state after call to pr_rcvd() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: caaea455773898bee9a0c59466a84256192e0980 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=caaea455773898bee9a0c59466a84256192e0980 commit caaea455773898bee9a0c59466a84256192e0980 Author: Greg Becker AuthorDate: 2023-09-09 23:38:24 +0000 Commit: Mark Johnston CommitDate: 2023-09-27 12:33:05 +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 ffd5e06c34b7..3c7e5c4cb4bb 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2429,6 +2429,10 @@ dontblock: VNET_SO_ASSERT(so); pr->pr_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);