From nobody Thu Jun 27 17:56:14 2024 X-Original-To: dev-commits-src-main@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 4W95pk4GYfz5Q7VP; Thu, 27 Jun 2024 17:56: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 4W95pk20JTz4b2s; Thu, 27 Jun 2024 17:56:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719510974; 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=ckO6SwbYrzsAH5CQvisH6MV6xvtEOIHeXm8MHMquWyU=; b=dbvd/JeiIioQXlLIQWafBuKHZauPYcnMAw91cDd9F8rbRp/+JKyv3tlWLg7TN3JIzyUG8Z X8RjnJ184rIOmJX1xlQBnuv032dRn0UbodLw+e4rlZm3HviGrN381bl3FGMIG4xoAGLCMy jKAC6J0b8tFffZQtrPnNacDewwFUEAEWmWHTyIyxhyyy+24g72f0w4k427a3hby2aWu2Ef bPP6VKhMRqq7R5gd7P1GgMVqcrtLotcsqDKIWXaUM10jwf2wB2JbsBUoPAyCw3nsWQg+il KnciK6D14GB/qPzRdeAqC5MgpRk/yBIi/qbhdLof5v6cRqTcjIbdspaqfyahUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719510974; a=rsa-sha256; cv=none; b=LVVeuH1iCYpwUHBgMOpilcyu3KoFfYEDKqFwwckWxhHCne79P/4OuD7K0K7CCP9inBim/l qdoDB9RA9dUPioolpag5MYrW0kdsnJJ05r2lSv90aR6yqFQYgzv0VYcaHMcIyiDcHVBmw0 rRH+rIm7Xy4CkdOnSvWENEQiF3zBBdngBVhLcTUTXgdvaDrduVGNjHilAnUBvT9DVr+vpY /HEhDbWnQ3JBnGgzuY2YTEmp7F0l4xfVv2wLhgCnFxVVB2nMto33jEYbcTF7E8vGgj0RlL WWp+e0ivLlAeNFKalRBH0Z8NZSL87BL2AHOfy4gQjcnmCDzws417uvKwMnpkxw== 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=1719510974; 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=ckO6SwbYrzsAH5CQvisH6MV6xvtEOIHeXm8MHMquWyU=; b=WRoMhmymlkxQdfOaeQDmbeLEwYE4L6shHrkMzCGglAbWupfgVV3q/6YXSLzKaIlRAcRTad vO4v9VtrAluQ9TPflVaWoAiIbcsk1BjT1Mn0NekMDAd/7aU2dMHtL0j/U+2nmAGVt/lOb0 ZZfKWljGRqJ1Ady7Bp0ka8iIBRmivwDVPqcZ/hg7bT116z7qRc/vopcWdCo8zMQoIz/LXF SitWEXuAIejmfegUvXbnCjXxP6VdmbDgP0ULFfla4awsSq490Gr2rMQRQSOGMat1pGtodl 1PCbCH9tTehIpqmMYjrEtbqwj8op1ykGBv7W7IwwvVqyhzd1svuGTJ8a9XdKvw== 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 4W95pk1BTnzM6s; Thu, 27 Jun 2024 17:56: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 45RHuEBq021827; Thu, 27 Jun 2024 17:56:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45RHuEdN021824; Thu, 27 Jun 2024 17:56:14 GMT (envelope-from git) Date: Thu, 27 Jun 2024 17:56:14 GMT Message-Id: <202406271756.45RHuEdN021824@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: 14fee5324a9b - main - tcp: improve failure handling in tcp_newtcpcb() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 14fee5324a9b76fff6e8aad266600eefab3ef335 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=14fee5324a9b76fff6e8aad266600eefab3ef335 commit 14fee5324a9b76fff6e8aad266600eefab3ef335 Author: Michael Tuexen AuthorDate: 2024-06-27 06:26:34 +0000 Commit: Michael Tuexen CommitDate: 2024-06-27 06:26:34 +0000 tcp: improve failure handling in tcp_newtcpcb() In case of a failure of tcp_newtcpcb, where NULL is returned, * call CC_ALGO(tp)->cb_destroy, after CC_ALGO(tp)->cb_init was called. * call khelp_destroy_osd(), after khelp_init_osd() was called. Reviewed by: glebius, rscheff MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D45753 --- sys/netinet/tcp_subr.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index b871d8416b19..438c9cf899c6 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2215,6 +2215,10 @@ tcp_newtcpcb(struct inpcb *inp) #ifdef TCP_HHOOK if (khelp_init_osd(HELPER_CLASS_TCP, &tp->t_osd)) { + if (CC_ALGO(tp)->cb_destroy != NULL) + CC_ALGO(tp)->cb_destroy(&tp->t_ccv); + CC_DATA(tp) = NULL; + cc_detach(tp); if (tp->t_fb->tfb_tcp_fb_fini) (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); refcount_release(&tp->t_fb->tfb_refcnt); @@ -2291,6 +2295,13 @@ tcp_newtcpcb(struct inpcb *inp) tp->t_pacing_rate = -1; if (tp->t_fb->tfb_tcp_fb_init) { if ((*tp->t_fb->tfb_tcp_fb_init)(tp, &tp->t_fb_ptr)) { + if (CC_ALGO(tp)->cb_destroy != NULL) + CC_ALGO(tp)->cb_destroy(&tp->t_ccv); + CC_DATA(tp) = NULL; + cc_detach(tp); +#ifdef TCP_HHOOK + khelp_destroy_osd(&tp->t_osd); +#endif refcount_release(&tp->t_fb->tfb_refcnt); return (NULL); }