Recommit these two together:
- r1.667 "Push kernel lock into ifioctl_get()"
locked before the switch() without unlocking in its cases
- r1.668 "Push kernel lock inside ifioctl_get()"
locked cases individually, as intended
I messed up splitting commits, but of course, Hrvoje managed to test a
CVS checkout right inbetween those two.
OK mpi mvs
-/* $OpenBSD: if.c,v 1.673 2022/11/09 10:41:18 dlg Exp $ */
+/* $OpenBSD: if.c,v 1.674 2022/11/09 13:08:36 kn Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
case SIOCGIFRDOMAIN:
case SIOCGIFGROUP:
case SIOCGIFLLPRIO:
- KERNEL_LOCK();
error = ifioctl_get(cmd, data);
- KERNEL_UNLOCK();
return (error);
}
switch(cmd) {
case SIOCGIFCONF:
+ KERNEL_LOCK();
NET_LOCK_SHARED();
error = ifconf(data);
NET_UNLOCK_SHARED();
+ KERNEL_UNLOCK();
return (error);
case SIOCIFGCLONERS:
+ KERNEL_LOCK();
error = if_clone_list((struct if_clonereq *)data);
+ KERNEL_UNLOCK();
return (error);
case SIOCGIFGMEMB:
+ KERNEL_LOCK();
NET_LOCK_SHARED();
error = if_getgroupmembers(data);
NET_UNLOCK_SHARED();
+ KERNEL_UNLOCK();
return (error);
case SIOCGIFGATTR:
+ KERNEL_LOCK();
NET_LOCK_SHARED();
error = if_getgroupattribs(data);
NET_UNLOCK_SHARED();
+ KERNEL_UNLOCK();
return (error);
case SIOCGIFGLIST:
+ KERNEL_LOCK();
NET_LOCK_SHARED();
error = if_getgrouplist(data);
NET_UNLOCK_SHARED();
+ KERNEL_UNLOCK();
return (error);
}
+ KERNEL_LOCK();
+
ifp = if_unit(ifr->ifr_name);
- if (ifp == NULL)
+ if (ifp == NULL) {
+ KERNEL_UNLOCK();
return (ENXIO);
+ }
NET_LOCK_SHARED();
NET_UNLOCK_SHARED();
+ KERNEL_UNLOCK();
+
if_put(ifp);
return (error);