From nobody Sat Sep 16 09:27:13 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 4Rnm0y2CsBz4ssJw; Sat, 16 Sep 2023 09:27:14 +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 4Rnm0y1nbdz4X0Z; Sat, 16 Sep 2023 09:27:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694856434; 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=qhW/+A/vbpMx9ynwEsWblHpkH0A1bO/TRvAxw+suAyM=; b=eJ2My8oxC927Lwc9lbQ02+1l2bEdoiMQ/sC+PVWLGM1juMV/hm+dCWFoEeMdrR9JTk/hWI fLMoKUHeOXMvRBX7esRVS4+9Kj6v1UQipuoYpPgDYlr2L2DFVp14S51Zwl46gH+MsUShDC QXYwtSSpPRz19HwhbxDSQkTfmSlOnUxgB4mm1n8ubJFdV3z9AAQ0QgcEXDEDHJM1iGJBdh VEiI4PzHNCxOfFDbY1crqXP/5xouQvSWT4mqQCAkjHEEzUyuRdfpuXqcoPao/q9gVphauW LnRPn6tiWqscuXu8t2xrufBJ6A1qv/9jg8VdicXBqz1QjiAd2r08ms1DF+kFRQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694856434; a=rsa-sha256; cv=none; b=td50uSYJzxrkGtzn1EEeVed1738Yy3zfJSi3CBJWYVKsc1jPEp9EXhvaPvs8VmBvzzuT7o k51OFNdn1LbqNq6mR6U914k/Pw0qzkdKuUpp6wKoGZtEd0Hkaa79pj7vweXnVuovBlrShA S0irf6s2FAzUd5H0l2GUTlbjKGZP6YeqBNGffdJQ1+PuWRdX6MwoPhP8/i6VtoHtpHq+Q+ 3YEPM8S0Y1CkbT68HIVDA+clq3Fy4NCYFTDxiy/8KCaQjBT7CaGrUVQjT+D/zG9BgDETJo mEG+6JrAm45/xrGPFxUvZvfTmSLIf/HWOb/ZOwMwHkT7LicczKO7QIj4QkNgBQ== 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=1694856434; 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=qhW/+A/vbpMx9ynwEsWblHpkH0A1bO/TRvAxw+suAyM=; b=atmPjO6TSBy8/BmnM7wWXvSjVpB5cZNxMU8dCAAlX3Il6ZNwy3QFg1Xl5e7ov7ZT/TVQTs 3NV2vZVgJ5hjFUXdjF4/Tj83NTlOLMq7ERhD3ME9meHAFe8VRtsdqTUgRmk317iGAUY4dw M5dvqzQaamrWedp9IAfjg6isIsNMePqAaryw9NKR/5gXXiv3zrNklQU7Z6UixOk5DbYMyF ej0LquHHrKrHkPZFZfNLyi55Lqua7pDW6zo/UWRZkg7pOE7zPT2r7OwTIZNVflne8EIRyv /7hT5OOkbuisRprlyexu5kHfXqOoJJ8zcLhaAV9t5SV+JuNk/L2M5lOkh23k0A== 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 4Rnm0y0sFfz11YP; Sat, 16 Sep 2023 09:27:14 +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 38G9RDIj016623; Sat, 16 Sep 2023 09:27:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38G9RDsn016620; Sat, 16 Sep 2023 09:27:13 GMT (envelope-from git) Date: Sat, 16 Sep 2023 09:27:13 GMT Message-Id: <202309160927.38G9RDsn016620@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: f44102411e1b - main - 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/main X-Git-Reftype: branch X-Git-Commit: f44102411e1b16363e91a074c9c403069c550e4d Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f44102411e1b16363e91a074c9c403069c550e4d commit f44102411e1b16363e91a074c9c403069c550e4d Author: Greg Becker AuthorDate: 2023-09-09 23:38:24 +0000 Commit: Mark Johnston CommitDate: 2023-09-15 16:59:46 +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 --- 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);