crash when unplugging urtwn usb wifi adapter

2018-04-13 Thread pki
>Synopsis:  page fault trap when removing urtwn Wifi adapter from the port
>Category:  kernel
>Environment:
System  : OpenBSD 6.3
Details : OpenBSD 6.3 (GENERIC.MP) #107: Sat Mar 24 14:21:59 MDT 
2018
 
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP

Architecture: OpenBSD.amd64
Machine : amd64
>Description:
I'm observing system crash if I remove the the TP-Link TL-WN725N
WiFi adapter from the port. The system reports kernel panic:

kernel: page fault trap, code=0
Stopped at softclock+0x16b: movq %rax,0(%rdx)

and drops to the debugger console. Pressing any key in debugger
causes kernel panic:

panic: mtx 0x81ac55f0: locking against myself
Stopped at db_enter+0x5: popq %rbp
TIDPID   UID PRFLAGS   PFLAGS  CPU COMMAND
423317 28010  35 0x100010  0x802   xconsole
db_enter() at db_enter+0x5
panic() at panic+0x129
__mtx_enter(80278000) at __mtx_enter+0x74
timeout_del(80278000) at timeout_del+0x17
xhci_xfer_done(967f170) at xhci_xfer_done+0xbf
xhci_event_dequeue(800033254f24) at xhci_event_dequeue+0xf3
xhci_softintr(800033254f20) at xhci_softintr+0x23
xhci_intr1(800033254f20) at xh ci_intr1+0x66
ukbd_cngetc(800033254f20,800033254f24,d) at ukbd_cngetc+0x39
wskbd_cngetc() at wskbd_cngetc+0x78
db_readline(0,0) at db_readline+0x45
db_read_line() at db_read_line+0x15
db_command_loop() at db_command_loop+0x83
db_trap() at db_trap+0x137

The problem is reproducible and it didn't occur in 6.2 (or it
frequency was so low that I didn't notice).

>How-To-Repeat:
1. Plug the  TP-Link TL-WN725N (might be it will be the same with
any other adapter handled by urtwn) into the port, assign it an
IP, bring it up (in my case I'm using WPA2 with static IPv4
address).
2. Start any dummy network activity, like ping www.yahoo.com
3. Remove the adapter from usb port -> it's likely that you will
get kernel crash.
>Fix:
The only potential workaround I can think of is to bring the
interface down before the adapter gets removed.


dmesg:
OpenBSD 6.3 (GENERIC.MP) #107: Sat Mar 24 14:21:59 MDT 2018
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4174385152 (3981MB)
avail mem = 4040790016 (3853MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0x8afad000 (32 entries)
bios0: vendor Apple Inc. version "MBA71.88Z.0166.B30.1706181928" date 06/18/2017
bios0: Apple Inc. MacBookAir7,1
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP HPET APIC SBST ECDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT 
SSDT DMAR MCFG
acpi0: wakeup devices PEG0(S3) EC__(S3) HDEF(S3) RP01(S3) RP02(S3) RP03(S4) 
ARPT(S4) RP05(S3) RP06(S3) SPIT(S3) XHC1(S3) ADP1(S3) LID0(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.23 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
acpihpet0: recalibrated TSC frequency 163279 Hz
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 100MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.01 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT,MELTDOWN
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 1 (application processor)
cpu2: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.01 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT,MELTDOWN
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 1, core 0, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.01 MHz
cpu3: 

Re: update63.html completeness

2018-04-13 Thread Raf Czlonka
Hi John,

Unless changes to the filesystem are required, there's no need for a
fresh install:

pkg_add sysclean

:^)

R

On Fri, Apr 13, 2018 at 11:13:12PM BST, j...@bitminer.ca wrote:
> On 2018-04-13 14:08, Stuart Henderson wrote:
> > On 2018/04/13 20:29, Theo Buehler wrote:
> > > On Thu, Apr 12, 2018 at 05:04:32PM -0600, j...@bitminer.ca wrote:
> > > > Hi,
> > > >
> > > > I noticed a couple of inconsistencies between upgrade63.html and
> > > > INSTALL..  They don't both state to remove man pages and
> > > > include files.
> > > 
> > > Thanks. Now that I see this mail, I remember that you sent a similar
> > > mail a while back which remained unanswered. Sorry about that.
> > > 
> > > What exactly should be listed by default on upgradeXX.html tends to
> > > lead
> > > to long discussions.
> 
> Seems to be true.
> 
> > > The fewer things the better. I list manuals because
> > > users are more likely to be confused by a stale manual than by a stale
> > > header.
> > > 
> > > If there are headers that are important to remove because they might
> > > interfere with ports building, they will (hopefully) be listed on
> > > upgradeXX.html.
> > 
> > To be honest, at least from the ports side, it's pretty unlikely that
> > these are going to be noticed in order to get listed.
> > 
> > Most people in a situation where failure to remove these is going to be
> > a real problem (i.e. bulk builders) either remove /usr/include/* (and
> > maybe others; /usr/libdata/* is another candidate) prior to upgrade,
> > or they use proot which will only populate the chroot with current
> > headers.
> 
> My full list was going to be: /usr/include /usr/X11R6/include /usr/share/man
> and as you say /usr/libdata.
> 
> What has caught me in the past:  sqlite3 removed from 6.0 base and a .h file
> which I can't remember at the moment.
> 
> The differences between 6.0 (say) and 6.2 are about 133 .h files and 2530
> files
> altogether [0].  For a serial upgrader like me, this amounts to sufficient
> number of
> noise files that I want to remove them.
> 
> (I didn't actually know this number until just now.  It seems installation
> is
> much more of a benefit to upgrading than I thought.  Not for disk space but
> for
> consistency.  Looks like I should reconsider my policy of upgrading all the
> time.)
> 
> And as a result of this perhaps the advice should be to upgrade rarely but
> mostly to install.  And to somehow preserve /etc/* that is needed
> post-install.
> 
> 
> John
> 
> 
> 
> [0] calculated with
> 
> $ for a in `find 6.2/amd64 -name '*.tgz'` ; do
> > tar tzf $a >> /tmp/62all.txt
> > done
> $ for a in `find 6.0/amd64 -name '*.tgz'` ; do
> > tar tzf $a >> /tmp/60all.txt
> > done
> $ sort /tmp/60all.txt > /tmp/60alls.txt
> $ sort /tmp/62all.txt > /tmp/62alls.txt
> $ comm -2 -3 /tmp/60alls.txt /tmp/62alls.txt | wc
> 25302530  144244
> 
> 
> > 
> > 
> > > > Here is a patch to fix upgrade63 but I'm not sure how to
> > > > go about fixing all INSTALL. an easy way.
> > > 
> > > They are built from /usr/src/distrib/notes/. You probably only have to
> > > edit m4.common.
> > > 
> 



Re: update63.html completeness

2018-04-13 Thread j

On 2018-04-13 14:08, Stuart Henderson wrote:

On 2018/04/13 20:29, Theo Buehler wrote:

On Thu, Apr 12, 2018 at 05:04:32PM -0600, j...@bitminer.ca wrote:
> Hi,
>
> I noticed a couple of inconsistencies between upgrade63.html and
> INSTALL..  They don't both state to remove man pages and
> include files.

Thanks. Now that I see this mail, I remember that you sent a similar
mail a while back which remained unanswered. Sorry about that.

What exactly should be listed by default on upgradeXX.html tends to 
lead

to long discussions.


Seems to be true.


The fewer things the better. I list manuals because
users are more likely to be confused by a stale manual than by a stale
header.

If there are headers that are important to remove because they might
interfere with ports building, they will (hopefully) be listed on
upgradeXX.html.


To be honest, at least from the ports side, it's pretty unlikely that
these are going to be noticed in order to get listed.

Most people in a situation where failure to remove these is going to be
a real problem (i.e. bulk builders) either remove /usr/include/* (and
maybe others; /usr/libdata/* is another candidate) prior to upgrade,
or they use proot which will only populate the chroot with current
headers.


My full list was going to be: /usr/include /usr/X11R6/include 
/usr/share/man

and as you say /usr/libdata.

What has caught me in the past:  sqlite3 removed from 6.0 base and a .h 
file

which I can't remember at the moment.

The differences between 6.0 (say) and 6.2 are about 133 .h files and 
2530 files
altogether [0].  For a serial upgrader like me, this amounts to 
sufficient number of

noise files that I want to remove them.

(I didn't actually know this number until just now.  It seems 
installation is
much more of a benefit to upgrading than I thought.  Not for disk space 
but for
consistency.  Looks like I should reconsider my policy of upgrading all 
the time.)


And as a result of this perhaps the advice should be to upgrade rarely 
but
mostly to install.  And to somehow preserve /etc/* that is needed 
post-install.



John



[0] calculated with

$ for a in `find 6.2/amd64 -name '*.tgz'` ; do

tar tzf $a >> /tmp/62all.txt
done

$ for a in `find 6.0/amd64 -name '*.tgz'` ; do

tar tzf $a >> /tmp/60all.txt
done

$ sort /tmp/60all.txt > /tmp/60alls.txt
$ sort /tmp/62all.txt > /tmp/62alls.txt
$ comm -2 -3 /tmp/60alls.txt /tmp/62alls.txt | wc
25302530  144244






> Here is a patch to fix upgrade63 but I'm not sure how to
> go about fixing all INSTALL. an easy way.

They are built from /usr/src/distrib/notes/. You probably only have to
edit m4.common.





Re: update63.html completeness

2018-04-13 Thread Stuart Henderson
On 2018/04/13 20:29, Theo Buehler wrote:
> On Thu, Apr 12, 2018 at 05:04:32PM -0600, j...@bitminer.ca wrote:
> > Hi,
> > 
> > I noticed a couple of inconsistencies between upgrade63.html and
> > INSTALL..  They don't both state to remove man pages and
> > include files.
> 
> Thanks. Now that I see this mail, I remember that you sent a similar
> mail a while back which remained unanswered. Sorry about that.
> 
> What exactly should be listed by default on upgradeXX.html tends to lead
> to long discussions. The fewer things the better. I list manuals because
> users are more likely to be confused by a stale manual than by a stale
> header.
> 
> If there are headers that are important to remove because they might
> interfere with ports building, they will (hopefully) be listed on
> upgradeXX.html.

To be honest, at least from the ports side, it's pretty unlikely that
these are going to be noticed in order to get listed.

Most people in a situation where failure to remove these is going to be
a real problem (i.e. bulk builders) either remove /usr/include/* (and
maybe others; /usr/libdata/* is another candidate) prior to upgrade,
or they use proot which will only populate the chroot with current
headers.


> > Here is a patch to fix upgrade63 but I'm not sure how to
> > go about fixing all INSTALL. an easy way.
> 
> They are built from /usr/src/distrib/notes/. You probably only have to
> edit m4.common.
> 



Re: update63.html completeness

2018-04-13 Thread Theo Buehler
On Thu, Apr 12, 2018 at 05:04:32PM -0600, j...@bitminer.ca wrote:
> Hi,
> 
> I noticed a couple of inconsistencies between upgrade63.html and
> INSTALL..  They don't both state to remove man pages and
> include files.

Thanks. Now that I see this mail, I remember that you sent a similar
mail a while back which remained unanswered. Sorry about that.

What exactly should be listed by default on upgradeXX.html tends to lead
to long discussions. The fewer things the better. I list manuals because
users are more likely to be confused by a stale manual than by a stale
header.

If there are headers that are important to remove because they might
interfere with ports building, they will (hopefully) be listed on
upgradeXX.html.

> Here is a patch to fix upgrade63 but I'm not sure how to
> go about fixing all INSTALL. an easy way.

They are built from /usr/src/distrib/notes/. You probably only have to
edit m4.common.