NetBSD Problem Report #54728

From gson@gson.org  Sun Dec  1 11:57:34 2019
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0F3D97A1A2
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  1 Dec 2019 11:57:34 +0000 (UTC)
Message-Id: <20191201115729.2AC78253F37@guava.gson.org>
Date: Sun,  1 Dec 2019 13:57:29 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: urtwn(4) locks up on WPA2 reconfiguration
X-Send-Pr-Version: 3.95

>Number:         54728
>Category:       kern
>Synopsis:       urtwn(4) locks up on WPA2 reconfiguration
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 01 12:00:00 +0000 2019
>Closed-Date:    Sat Dec 14 17:10:57 +0000 2019
>Last-Modified:  Sat Dec 14 17:10:57 +0000 2019
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current, source date 2019.11.29.14.15.41
>Organization:

>Environment:
System: NetBSD
Architecture: x86_64
Machine: amd64
>Description:

The urtwn(4) driver hangs when a RTL8188CUS based USB WiFi adapter is
configured with WPA2 encryption for the second time.  I have three such
adapters and it happens consistently with all of them, with multiple
USB host controller types (OHCI, EHCI, XHCI).

A RTL8188EU based adapter fails differently, and adapters on UHCI also
fail differently; those failures are outside the scope of this PR.

To reproduce:

In the unlikely case that you don't already have a WiFi access point
using WPA2 encryption, set one up.

Save the following as test-wpa2.sh and edit the IP addresses and masks
to match your access point configuration.  Set ap_ip and ap_mask to
the IP address and netmask of the access point, respectively, and
our_ip to any unused IP address on the same network.

#!/bin/sh
set -ex
wifi_if="$1"
ap_ip=192.168.100.1
ap_mask=255.255.255.0
our_ip=192.168.100.2
wpa_supplicant -i $wifi_if -c ./wpa_supplicant.conf >wpa_supplicant.log &
ifconfig $wifi_if $our_ip netmask $ap_mask
ifconfig $wifi_if up
ping -n -c 20 $ap_ip
wpa_cli terminate
sleep 5
ifconfig $wifi_if down
echo "pass"

Save the following as ./wpa_supplicant.conf and edit the SSID and
password to match your access point configuration:

ctrl_interface=/var/run/wpa_supplicant/
ctrl_interface_group=wheel
network={
        ssid="YOUR_SSID_HERE"
        psk="YOUR_WIFI_PASSWORD_HERE"
}

Plug in a urtwn(4) USB WiFi adapter.

Run

  sh test-wpa2.sh urtwn0

This is expected to succeed and print "pass" at the end.  Note that it
is normal to lose about half the ping packets while the interface is
being configured.

Then run the script again:

  sh test-wpa2.sh urtwn0

This time, the script will fail, and the console will log the
message "urtwn0: timeout waiting for firmware readiness".

I can send adapters to the first two developers who express a
serious interest in investigating this bug, for free and with
no need to return them.

>How-To-Repeat:

See above.

>Fix:

>Release-Note:

>Audit-Trail:
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54728: urtwn(4) locks up on WPA2 reconfiguration
Date: Sun, 1 Dec 2019 12:51:36 -0000 (UTC)

 gson@gson.org (Andreas Gustafsson) writes:

 >This time, the script will fail, and the console will log the
 >message "urtwn0: timeout waiting for firmware readiness".

 Does this help?

 Index: if_urtwn.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/if_urtwn.c,v
 retrieving revision 1.75
 diff -p -u -r1.75 if_urtwn.c
 --- if_urtwn.c  26 Nov 2019 10:34:16 -0000      1.75
 +++ if_urtwn.c  1 Dec 2019 12:51:01 -0000
 @@ -3467,6 +3465,7 @@ urtwn_load_firmware(struct urtwn_softc *
         }

         if (urtwn_read_1(sc, R92C_MCUFWDL) & R92C_MCUFWDL_RAM_DL_SEL) {
 +               urtwn_write_1(sc, R92C_MCUFWDL, 0);
                 if (ISSET(sc->chip, URTWN_CHIP_88E) ||
                     ISSET(sc->chip, URTWN_CHIP_92EU))
                         urtwn_r88e_fw_reset(sc);


 -- 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: Andreas Gustafsson <gson@gson.org>
To: mlelstv@serpens.de (Michael van Elst)
Cc: gnats-bugs@netbsd.org
Subject: Re: kern/54728: urtwn(4) locks up on WPA2 reconfiguration
Date: Sun, 1 Dec 2019 16:17:06 +0200

 Michael van Elst wrote:
 >  Does this help?

 It does!  Can you commit it, please?
 -- 
 Andreas Gustafsson, gson@gson.org

From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54728 CVS commit: src/sys/dev/usb
Date: Sun, 1 Dec 2019 21:01:19 +0000

 Module Name:	src
 Committed By:	mlelstv
 Date:		Sun Dec  1 21:01:19 UTC 2019

 Modified Files:
 	src/sys/dev/usb: if_urtwn.c

 Log Message:
 Reset MCU ready status before resetting the MCU.
 Fixes PR kern/54728


 To generate a diff of this commit:
 cvs rdiff -u -r1.75 -r1.76 src/sys/dev/usb/if_urtwn.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: gson@NetBSD.org
State-Changed-When: Sun, 01 Dec 2019 21:08:23 +0000
State-Changed-Why:
Fix committed by mlelstv, thanks!


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: gson@NetBSD.org
State-Changed-When: Sat, 14 Dec 2019 11:14:43 +0000
State-Changed-Why:
I see that mlelstv has submitted pullup-9 request #551.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54728 CVS commit: [netbsd-9] src/sys/dev/usb
Date: Sat, 14 Dec 2019 12:26:05 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Dec 14 12:26:05 UTC 2019

 Modified Files:
 	src/sys/dev/usb [netbsd-9]: if_urtwn.c

 Log Message:
 Pull up following revision(s) (requested by mlelstv in ticket #551):

 	sys/dev/usb/if_urtwn.c: revision 1.76
 	sys/dev/usb/if_urtwn.c: revision 1.77

 Reset MCU ready status before resetting the MCU.

 Fixes PR kern/54728

 Don't deregister twice with pmf.


 To generate a diff of this commit:
 cvs rdiff -u -r1.71.2.1 -r1.71.2.2 src/sys/dev/usb/if_urtwn.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54728 CVS commit: [netbsd-8] src/sys/dev/usb
Date: Sat, 14 Dec 2019 12:33:47 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Dec 14 12:33:47 UTC 2019

 Modified Files:
 	src/sys/dev/usb [netbsd-8]: if_urtwn.c

 Log Message:
 Pull up following revision(s) (requested by mlelstv in ticket #1472):

 	sys/dev/usb/if_urtwn.c: revision 1.76

 Reset MCU ready status before resetting the MCU.
 Fixes PR kern/54728


 To generate a diff of this commit:
 cvs rdiff -u -r1.53.2.5 -r1.53.2.6 src/sys/dev/usb/if_urtwn.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Sat, 14 Dec 2019 17:10:57 +0000
State-Changed-Why:
Pulled up.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.45 2018/12/21 14:23:33 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.