From nobody Thu Apr 28 21:06:43 2022 X-Original-To: usb@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 023941AA9EC1 for ; Thu, 28 Apr 2022 21:06:44 +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 4Kq7Tb51tsz3vXB for ; Thu, 28 Apr 2022 21:06:43 +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 8D21C1FEB2 for ; Thu, 28 Apr 2022 21:06:43 +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 23SL6hn9096538 for ; Thu, 28 Apr 2022 21:06:43 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 23SL6hIq096537 for usb@FreeBSD.org; Thu, 28 Apr 2022 21:06:43 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: usb@FreeBSD.org Subject: [Bug 263638] uath driver for Atheros AR5523 USB WiFi chipset fails to initialize Date: Thu, 28 Apr 2022 21:06:43 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: usb X-Bugzilla-Version: 13.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: jgibbons@protogate.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: usb@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: 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: FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-usb List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651180003; 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=9DF3u8czDF92sgKqRGJ4gKc7J9b3YDindMaYyu34I6c=; b=UzmaRVwF1nYcybmMzGuYWP1ODujVva0+7n/lifm4Y8eXWftjcg2DqhPcz06umbyh16AVv4 vK1gsomw0yIlarbVFRZ9OSdNeKMR0JiQZIBo5qEr5nNTmUDFM6PvCZesdXynLotOstDVyH bFwkvqoHWJ6NOTfQrMZjjNEvpZ500HODfO05EeUVrB0nvp9NwaSsd7imxg1S5F72y0aj6k bpvWjWNscMOTk5OPdlzXZLz03EOTr/v4SjMoZ7Ytun9cQgTvqEjpNj7lasvV1vdAWTq/zR +HkgZw2MqzTrc0fwP9jwDfn6e7OrbC328aorfOLrLBoxVLje1CGwx+2ByO5+Yw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651180003; a=rsa-sha256; cv=none; b=BvNTGpEL51PR3OPFZOY1v+PKlZi6ugsmNmERvlhw+c3Etg85nd1draJQCPHzkh0Ce/YHXv 243/jcCO/AwG2YHPxQzAWnsFZA34kdp6mJAsAIVR3yPkPCD4BK7A0+nFvTnFv6Zy6+4yJY j8E9m3SLU3tAwVAvrc+wE61SQaaKV37eFpSitm3VFXnZ0zwAN/wK/6a9QNF2Q9jRC1pf+2 K+B+lRwfOh1+Fzj/LcMnjcSKf56F5OLfdzCAY6WWHZUIsA9L6U5IWC6w8goyMn6ygTK5lN leBEdd0B4hYHA9rVVmpnTsMN519NfMtSrGfGw8aaU1kioZvDZ68q3AigPlzzsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D263638 Bug ID: 263638 Summary: uath driver for Atheros AR5523 USB WiFi chipset fails to initialize Product: Base System Version: 13.1-STABLE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: usb Assignee: usb@FreeBSD.org Reporter: jgibbons@protogate.com uath devices fail to initialize, with lines such as these in the dmesg outp= ut: ugen1.4: at usbus1 uath0 on uhub3 uath0: on usbu= s1 uath0: uath_cmdeof: invalid WDC msg length 671088640; msg ignored uath0: timeout waiting for reply to cmd 0x4 (4) uath0: could not read capability 2 uath0: could not get device capabilities device_attach: uath0 attach returned 35 The problem is caused by code which was added to /usr/src/sys/dev/usb/wlan/if_uath.c several years ago ( git 6acad03d6f245dd60ef4f50d03483dad08aff5f9 ), which added an extra swapping of the byte-order of a hdr->len field from big-endi= an to the host's native byte order BEFORE calling a uath_cmdeof() function whi= ch expects that hdr->len field to still be in big-endian format. uath_cmdeof() then calls be32toh() to swap that field again, which puts it back into the wrong byte-order, and subsequent operations all fail (as can be seen by the "invalid WDC msg length 671088640" error message above: 671088640 is the 32-bit-byte-swapped version of the decimal number 40). Below is a patch which fixes this problem, and makes my Netgear WPN111 useable: diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index df7e1d7c396..b285ae06260 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -2244,7 +2244,7 @@ uath_cmdeof(struct uath_softc *sc, struct uath_cmd *c= md) u_int olen; if (sizeof(*hdr) > hdr->len || - hdr->len >=3D UATH_MAX_CMDSZ) { + hdr->len > UATH_MAX_CMDSZ) { device_printf(sc->sc_dev, "%s: invalid WDC msg length %u; " "msg ignored\n", __func__, hdr->len); @@ -2360,11 +2360,12 @@ uath_intr_rx_callback(struct usb_xfer *xfer, usb_error_t error) usbd_copy_out(pc, 0, cmd->buf, actlen); hdr =3D (struct uath_cmd_hdr *)cmd->buf; - hdr->len =3D be32toh(hdr->len); - if (hdr->len > (uint32_t)actlen) { + // hdr->len =3D be32toh(hdr->len); // Don't do this here! + // Later code expects it to remain big-end= ian! + if (be32toh(hdr->len) > (uint32_t)actlen) { device_printf(sc->sc_dev, "%s: truncated xfer (len %u, actlen %d)\n", - __func__, hdr->len, actlen); + __func__, be32toh(hdr->len), actlen); goto setup; } My version of FreeBSD, and the USB WiFi device I tested this with, is here: root@romulus:/usr/src/sys/dev/usb/wlan # uname -a FreeBSD romulus.jag.protogate.com 13.1-STABLE FreeBSD 13.1-STABLE #0 stable/13-n250407-0ae09fb966d: Wed Apr 13 07:40:07 PDT 2022=20=20=20=20 root@romulus.jag.protogate.com:/usr/obj/usr/src/amd64.amd64/sys/JAG_KERNEL_= A64 amd64 root@romulus:/usr/src/sys/dev/usb/wlan # usbconfig -d 6.2 dump_device_desc ugen6.2: at usbus6, cfg=3D0 md=3DHOST s= pd=3DHIGH (480Mbps) pwr=3DON (500mA) bLength =3D 0x0012=20 bDescriptorType =3D 0x0001=20 bcdUSB =3D 0x0200=20 bDeviceClass =3D 0x00ff bDeviceSubClass =3D 0x0000=20 bDeviceProtocol =3D 0x0000=20 bMaxPacketSize0 =3D 0x0040=20 idVendor =3D 0x1385=20 idProduct =3D 0x5f00=20 bcdDevice =3D 0x0001=20 iManufacturer =3D 0x0001 iProduct =3D 0x0002 iSerialNumber =3D 0x0003 <1.0> bNumConfigurations =3D 0x0001 --=20 You are receiving this mail because: You are the assignee for the bug.=