summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpirofti <pirofti@openbsd.org>2017-02-04 15:02:46 +0000
committerpirofti <pirofti@openbsd.org>2017-02-04 15:02:46 +0000
commit6d61506fadd93da9c9941b7ed873800f10c46807 (patch)
tree932c8c929a234aa737c0b43b32b4d03d12243fef
parentInclude netinet/in.h for in_addr_t now it has moved out of sys/types.h. (diff)
downloadwireguard-openbsd-6d61506fadd93da9c9941b7ed873800f10c46807.tar.xz
wireguard-openbsd-6d61506fadd93da9c9941b7ed873800f10c46807.zip
Prevent netlock related deadlock with the X server during iwm(4) scans.
The issue appears at least with 7265 and 8260 chips as confirmed by stsp@, tb@ and myself. Fixed by unlocking NET_LOCK() at the beginning of iwmioctl() and relocking it at the end. Guidance and ok mpi@, ok stsp@.
-rw-r--r--sys/dev/pci/if_iwm.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c
index 3a6a3c15257..f73c71f1e12 100644
--- a/sys/dev/pci/if_iwm.c
+++ b/sys/dev/pci/if_iwm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwm.c,v 1.160 2017/01/29 09:44:25 stsp Exp $ */
+/* $OpenBSD: if_iwm.c,v 1.161 2017/02/04 15:02:46 pirofti Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@@ -6133,14 +6133,18 @@ iwm_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
struct ifreq *ifr;
int s, err = 0;
+ /* XXXSMP breaks atomicity */
+ rw_exit_write(&netlock);
/*
* Prevent processes from entering this function while another
* process is tsleep'ing in it.
*/
err = rw_enter(&sc->ioctl_rwl, RW_WRITE | RW_INTR);
- if (err)
+ if (err) {
+ rw_enter_write(&netlock);
return err;
+ }
s = splnet();
@@ -6186,6 +6190,7 @@ iwm_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
splx(s);
rw_exit(&sc->ioctl_rwl);
+ rw_enter_write(&netlock);
return err;
}