From nobody Sun Feb 13 10:48:43 2022 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 A934A1948DAF; Sun, 13 Feb 2022 10:48:43 +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 4JxPGg4GFZz4kTP; Sun, 13 Feb 2022 10:48:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644749323; 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=x5F82wxqXDHl6psjM+2Dx8215vlr7BYhYXiOWFKk03Y=; b=Q8oEhra88kt7Tx/YRnb6h7IZWiiI/CPwh6rVXOO21CIyaMPjXYCAWY2ZZhRd9bsDuY2m0Q m+8GLGW/wMWxl3edu1iyCr685ef9EG7bfM19HM7nDm3+Uw+mo6FNEmZoLpPi40p1APFBVc P6CAuhOmptUTsJ6g2nx+76S/bIMJJyXHg19xXNx3qzKiv6j+w8vHSHDxCBtXW0kxe1MdOc 8V+GGd7bX7c9LLgRV1SRX/Nwpc0hn55PYb6Eim3BLiPiSAYSrR/2E3jMxfdtwXpwVGPlfe ZRv6bC44UedqfNl2EtCevreQiYHFlNE5Z2WIl3pNqY5QzRV1G+5IT6D9+9ELpw== 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 7254519DFE; Sun, 13 Feb 2022 10:48:43 +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 21DAmhBP086565; Sun, 13 Feb 2022 10:48:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21DAmhFi086564; Sun, 13 Feb 2022 10:48:43 GMT (envelope-from git) Date: Sun, 13 Feb 2022 10:48:43 GMT Message-Id: <202202131048.21DAmhFi086564@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: ea25a6af57e0 - stable/12 - netmap: fix LOR in iflib_netmap_register 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: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ea25a6af57e0ce1551341e3b1652233cdb11bee1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644749323; 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=x5F82wxqXDHl6psjM+2Dx8215vlr7BYhYXiOWFKk03Y=; b=wWt4dNyA/PZdjuY4wwmxi4MUhL6SNcB1PWwwe/LnyiKDjhyVBswIGl0eTU7TE2VwdpZObj jvN0jAAvDNxx+PflQV6oATLuD/fItFid1/WYBIePpXoD0ydbKpcjgI6FkrEyuRjxpeox7a oRPXaUhJT1dNm3v1HWyedYjimACfSHkdrzKldpzhD6DUcocWxoHpqd6BL9iMaj1LfFzhDC Qnye1WMlM5LiI5rKhg/jp7Mi8yeA4Hyz+73AbKBKkbTDdvWgSceZdzPpvEX/15xZHYSshc sM9j4FXZHNVITAIy9Txh1czw++nnf2Fisrvgh+8FmFVYdrKjJ3/r9z5AAWwPEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644749323; a=rsa-sha256; cv=none; b=p2rXvPgrfEvyRA3PIvQHw3GPZZYZ/m3yrzacMq9om1efhDxD20ujjXl48n1BOLkEL06WrV 9gXqVE4/9oyr4GgPBd4QlxwDQzAlYIWldQAn0M0mbqD8WdQC9MaTDcBsMS9U2jDCORDtzN ENXHTtXJPdt+ZhhLOEmPGveaOxsbOppVkzd3027fnAZyZAG7xavj1ApTU1bZsH+zDD2oR3 9NfEnJz7h8Mv8PNOp+75HL/FAnWgvaCwoiP5d2VUd/5q8Yr0y26DuXPVcANzDCPwbk+Yue A2Rr3IQ0U3qbAMxzMDSswvXV/89UKunmO6X4GhuI//lxF2t48trm+MEfao2lYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=ea25a6af57e0ce1551341e3b1652233cdb11bee1 commit ea25a6af57e0ce1551341e3b1652233cdb11bee1 Author: Vincenzo Maffione AuthorDate: 2022-01-14 21:09:04 +0000 Commit: Vincenzo Maffione CommitDate: 2022-02-13 10:20:55 +0000 netmap: fix LOR in iflib_netmap_register In iflib_device_register(), the CTX_LOCK is acquired first and then IFNET_WLOCK is acquired by ether_ifattach(). However, in netmap_hw_reg() we do the opposite: IFNET_RLOCK is acquired first, and then CTX_LOCK is acquired by iflib_netmap_register(). Fix this LOR issue by wrapping the CTX_LOCK/UNLOCK calls in iflib_device_register with an additional IFNET_WLOCK. This is safe since the IFNET_WLOCK is recursive. MFC after: 1 month (cherry picked from commit e0e12405285b61a724c646b8f8e99e3ec775291e) --- sys/net/iflib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index d2d073b82945..f057b7deba91 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -5021,6 +5021,7 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct ifp = ctx->ifc_ifp; iflib_reset_qvalues(ctx); + IFNET_WLOCK(); CTX_LOCK(ctx); if ((err = IFDI_ATTACH_PRE(ctx)) != 0) { device_printf(dev, "IFDI_ATTACH_PRE failed %d\n", err); @@ -5218,6 +5219,7 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct iflib_add_device_sysctl_post(ctx); ctx->ifc_flags |= IFC_INIT_DONE; CTX_UNLOCK(ctx); + IFNET_WUNLOCK(); return (0); @@ -5233,6 +5235,7 @@ fail_intr_free: iflib_free_intr_mem(ctx); fail_unlock: CTX_UNLOCK(ctx); + IFNET_WUNLOCK(); iflib_deregister(ctx); fail_ctx_free: device_set_softc(ctx->ifc_dev, NULL);