From nobody Wed Sep 28 10:13:21 2022 X-Original-To: net@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 4Mcsl53pvsz4dVp9 for ; Wed, 28 Sep 2022 10:13:21 +0000 (UTC) (envelope-from bugzilla-noreply@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 4Mcsl51qnRz3FVp for ; Wed, 28 Sep 2022 10:13:21 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4Mcsl50t5TzRJT for ; Wed, 28 Sep 2022 10:13:21 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 28SADLNB040158 for ; Wed, 28 Sep 2022 10:13:21 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 28SADLWR040157 for net@FreeBSD.org; Wed, 28 Sep 2022 10:13:21 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 252165] usb network and mii bus media status race condition Date: Wed, 28 Sep 2022 10:13:21 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: ali.abdallah@suse.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664360001; 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: in-reply-to:in-reply-to:references:references; bh=8ljXFKKT5ACTYhkJd19qtK5pHelVrJtgHUfBqjBOfWE=; b=TWS2UzN6ezg28i8i7iVQkIiNsXhN7tcx8HYIgBOYmsRkocy5D2NHRiLEfirXqPPBnqT05j xGCQg5dVN0KD13pPLUVwVISHEApFL2et0fnyLNWTaaUeLPxppzJwQX10f+ynLlfmQBbhsY zSS5LkXgPn/rXuo2eow58CQFS4rARncLovW2MOEZgAXwsuISryFHRIKZc8YDH8P26NaWc9 aAeB/6utHXECGR8v1n+AhQz3H8UJjDFfDV0XoWoObKwJUEW2PgfdksG73VADGLZRm2vfAO fVCXe59KPLMYc7A8YklcDgrEXm3JgmpuugadIvm8B2Noxj81OhU1hsxOh0nlJw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664360001; a=rsa-sha256; cv=none; b=CiXsQSOXuW+RhL3OwxZl5PpiOQklYbYOd9iSvWlEWGkXhJ24wu7JcM1CYq9txDHf/Zk8d7 CUDdYoDFe262eCHDpv7V5nL/czouLHoCsr/Id1Q6pcTmwbBwxj/gH8BC1+yhBzqyt/9tc8 Gd7DTA1vMwQFUTEO1XVNL0TKsdVvubvVWc8lovQ6lDplIyFFpuwxOjq4Nl+OjJWb+RarFd s1tVWnvGvCJxR01T8NKlkqvHfxVbvhB4tDM6zQ2siFHCykBFJLnftTktRJGLQObCBHaqnk aFxM2Z12GwMmI/w13OFvJCqQuirJBtSTKGACSVbgh6PZ5OVBPzfWx//6RDUWHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D252165 --- Comment #24 from Ali Abdallah --- Created attachment 236901 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D236901&action= =3Dedit dtrace ure usb traces I got another machine on which I didn't apply the workaround, running 13.1, with a USB Lan adapter that uses if_ure, I used the following dtrace probes. dtrace -n 'fbt:miibus:mii_pollstat:*,fbt:uether:ue_tick_task:*,fbt:if_ure:ure_tick:*,= fbt:if_ure:ure_ifmedia_sts:*,fbt:miibus:mii_tick:*,fbt:miibus:miibus_linkch= g:*, fbt:usb:* { printf("%p", curthread); }' You can see from the attached debug log (numbered lines) 1 48573 ure_ifmedia_sts:entry fffffe00dc75c720 1 48475 mii_pollstat:entry fffffe00dc75c720 But before exit entry of re_ifmedia_sts:return of thread fffffe00dc75c720, = you can see: 1052 0 48573 ure_ifmedia_sts:entry fffffe00e00271e0 1053 2 27791 usb_command_wrapper:entry fffffe0082a17ac0 1054 2 27738 usbd_callback_wrapper:entry fffffe0082a17ac0 1055 0 48475 mii_pollstat:entry fffffe00e00271e0 And that exactly when the link up/down happened. So thread fffffe00e00271e0 managed to go ahead and call mii_pollstat, acqui= ring the sc mutex, despite that thread fffffe00dc75c720 didn't release it yet, y= ou can see that the return from "polling the media state" on thread fffffe00dc75c720 comes way after the ure_ifmedia_sts:entry of thread fffffe00e00271e0 1517 3 48476 mii_pollstat:return fffffe00dc75c720 1518 3 48574 ure_ifmedia_sts:return fffffe00dc75c720 __snip if_ure__=20 ure_ifmedia_sts { ... URE_LOCK(sc);=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 mii_pollstat(mii); ifmr->ifm_active =3D mii->mii_media_active; ifmr->ifm_status =3D mii->mii_media_status; URE_UNLOCK(sc); } __snip__ The mutex locked/released by URE_LOCK, is the same mutex used in if_ure, USB xfer and USB transfer, so I guess something is not playing well in the release/acquire sequence... Will try if time permits to dig more into the USB transfer/process code, bu= t I have to say that I'm extremely surprised that this bug didn't attract much attention, it actually renders any USB Ethernet device unusable on FreeBSD.= .. --=20 You are receiving this mail because: You are the assignee for the bug.=