From nobody Tue Apr 05 11:52:55 2022 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 253C81A89AD6; Tue, 5 Apr 2022 11:52:56 +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 4KXmHD0VGjz3Mmq; Tue, 5 Apr 2022 11:52:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649159576; 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=xUxUofXPxuToPIEtb3siPbG0j+r4t/Q7ijqMbpmKFT4=; b=naYCrQD+Ueg9SJi/6QfdzE4NjQg+T8VqQHQ+AJGN/Bnu84mA8llO1qAvqnV6FgG8Pm8c7b raVhYgrJuJiANPXnDpS8bdY9fWI0bIsddCXK1ONm5luExnHqOIbOxZEl33Tvaz+0WCWL9j GJCrESjsUmvUVbASgIShNsjBz0eymcXXAupD4TYA8P+H+jMRskhGEa0ZkiiiIxOYP+Yy49 lKW/6Nf1wRpfIV8v1iRjKyz7TLjAHjMWGuPdr9zAlPh65Tf3cGKS5ncTBykmwnsNd4AFLG muWtsnR3NoLup2/UBigrPJeR6MMdRVjAa92HqIgYrNetopw5lAFAD33YifZKqg== 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 E4DD925F30; Tue, 5 Apr 2022 11:52:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 235BqtRd001684; Tue, 5 Apr 2022 11:52:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 235BqtMx001682; Tue, 5 Apr 2022 11:52:55 GMT (envelope-from git) Date: Tue, 5 Apr 2022 11:52:55 GMT Message-Id: <202204051152.235BqtMx001682@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: ccdfd621d070 - main - tcp cc: don't recurse on non recursive mutex 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: ccdfd621d070c11964984d81f66c2bd38f8072f4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649159576; 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=xUxUofXPxuToPIEtb3siPbG0j+r4t/Q7ijqMbpmKFT4=; b=NdnJOnhuq0P3yENNbuHbWa9BGkggxvnNIkv/f8P/NarpW9EDkTWJX+e/ynNQvub3yEHPOo yviUVcAA3m6WyQN3Zl+BF0DI6td2A245o5i0Oa0fizJ0Zjyi8KH+qv6EFreIB1Ul1qfRVw LpzPa25/ldVB6Jz0y9yu2JsmKJdott0bJnQXqYhpVgC9H7bFo7gJwcjnMwSq2XiPQnHVWS gv4L8A/if8Na8yukyGK+5qL0SA8336yjCMz7K2c6sJIllhZek8U7REknhTwHghY4Tpvk7m OHwhF3RBU2t3FnCjgkl0N/VQifLxD9J8Pc+4+odpV3Mj6RWOF3lsDxJ4C/j1vw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649159576; a=rsa-sha256; cv=none; b=VcnKydTxwHmzTF2Pb5orEF3DmJ3TQA2DLYCMC0GjQjjuHVEZPL68i/ssWC52YXyZVlEKYZ ILFQG3alEzWrj9zm8Fy9gEB75riWVVs9AQvDh+aYZo1QILVEeHIXz4vTR4P03Zt/Pvld3l 4tsFeCtDntldyjyhy50JIbTD496bbOlmjx5kg4Q5ffLy7VuY/ZV274xF+ilf8HquwK4Vrn XJaXkLR30O/dLhdGzhL8oYmW/0o1VXQjZlUsfCzOrlHUy5n37ccCLAtlkX9RQH2q+GtzMU 0GeVyzYE4Tvnomqos9p5jXFR9azgm3KtnfOZ9pycEaSW3Ys0YrhjCJxPSYH7iQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=ccdfd621d070c11964984d81f66c2bd38f8072f4 commit ccdfd621d070c11964984d81f66c2bd38f8072f4 Author: Michael Tuexen AuthorDate: 2022-04-05 11:50:49 +0000 Commit: Michael Tuexen CommitDate: 2022-04-05 11:52:36 +0000 tcp cc: don't recurse on non recursive mutex This issue was found by syzkaller. Reviewed by: rrs Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D34743 --- sys/netinet/cc/cc.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sys/netinet/cc/cc.c b/sys/netinet/cc/cc.c index 55a5f6ef652e..a009998ca920 100644 --- a/sys/netinet/cc/cc.c +++ b/sys/netinet/cc/cc.c @@ -280,15 +280,12 @@ cc_init(void) /* * Returns non-zero on success, 0 on failure. */ -int -cc_deregister_algo(struct cc_algo *remove_cc) +static int +cc_deregister_algo_locked(struct cc_algo *remove_cc) { struct cc_algo *funcs; int found = 0; - /* Remove algo from cc_list so that new connections can't use it. */ - CC_LIST_WLOCK(); - /* This is unlikely to fail */ STAILQ_FOREACH(funcs, &cc_list, entries) { if (funcs == remove_cc) @@ -296,25 +293,36 @@ cc_deregister_algo(struct cc_algo *remove_cc) } if (found == 0) { /* Nothing to remove? */ - CC_LIST_WUNLOCK(); return (ENOENT); } /* We assert it should have been MOD_QUIESCE'd */ KASSERT((remove_cc->flags & CC_MODULE_BEING_REMOVED), ("remove_cc:%p does not have CC_MODULE_BEING_REMOVED flag", remove_cc)); if (cc_check_default(remove_cc)) { - CC_LIST_WUNLOCK(); return(EBUSY); } if (remove_cc->cc_refcount != 0) { - CC_LIST_WUNLOCK(); return (EBUSY); } + /* Remove algo from cc_list so that new connections can't use it. */ STAILQ_REMOVE(&cc_list, remove_cc, cc_algo, entries); - CC_LIST_WUNLOCK(); return (0); } +/* + * Returns non-zero on success, 0 on failure. + */ +int +cc_deregister_algo(struct cc_algo *remove_cc) +{ + int ret; + + CC_LIST_WLOCK(); + ret = cc_deregister_algo_locked(remove_cc); + CC_LIST_WUNLOCK(); + return (ret); +} + /* * Returns 0 on success, non-zero on failure. */ @@ -628,7 +636,8 @@ cc_modevent(module_t mod, int event_type, void *data) * If -f was used and users are still attached to * the algorithm things are going to go boom. */ - err = cc_deregister_algo(algo); + err = cc_deregister_algo_locked(algo); + CC_LIST_WUNLOCK(); if ((err == 0) && (algo->mod_destroy != NULL)) { algo->mod_destroy(); }