Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

X25 remove bkl in subscription ioctls

Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

andrew hendry and committed by
David S. Miller
5595a1a5 5892b9e9

+12 -10
+2
include/net/x25.h
··· 315 315 extern rwlock_t x25_route_list_lock; 316 316 extern struct list_head x25_forward_list; 317 317 extern rwlock_t x25_forward_list_lock; 318 + extern struct list_head x25_neigh_list; 319 + extern rwlock_t x25_neigh_list_lock; 318 320 319 321 extern int x25_proc_init(void); 320 322 extern void x25_proc_exit(void);
+4 -8
net/x25/af_x25.c
··· 1415 1415 rc = x25_route_ioctl(cmd, argp); 1416 1416 break; 1417 1417 case SIOCX25GSUBSCRIP: 1418 - lock_kernel(); 1419 1418 rc = x25_subscr_ioctl(cmd, argp); 1420 - unlock_kernel(); 1421 1419 break; 1422 1420 case SIOCX25SSUBSCRIP: 1423 1421 rc = -EPERM; 1424 1422 if (!capable(CAP_NET_ADMIN)) 1425 1423 break; 1426 - lock_kernel(); 1427 1424 rc = x25_subscr_ioctl(cmd, argp); 1428 - unlock_kernel(); 1429 1425 break; 1430 1426 case SIOCX25GFACILITIES: { 1431 1427 struct x25_facilities fac = x25->facilities; ··· 1642 1646 dev_put(dev); 1643 1647 1644 1648 if (cmd == SIOCX25GSUBSCRIP) { 1649 + read_lock_bh(&x25_neigh_list_lock); 1645 1650 x25_subscr.extended = nb->extended; 1646 1651 x25_subscr.global_facil_mask = nb->global_facil_mask; 1652 + read_unlock_bh(&x25_neigh_list_lock); 1647 1653 rc = copy_to_user(x25_subscr32, &x25_subscr, 1648 1654 sizeof(*x25_subscr32)) ? -EFAULT : 0; 1649 1655 } else { 1650 1656 rc = -EINVAL; 1651 1657 if (x25_subscr.extended == 0 || x25_subscr.extended == 1) { 1652 1658 rc = 0; 1659 + write_lock_bh(&x25_neigh_list_lock); 1653 1660 nb->extended = x25_subscr.extended; 1654 1661 nb->global_facil_mask = x25_subscr.global_facil_mask; 1662 + write_unlock_bh(&x25_neigh_list_lock); 1655 1663 } 1656 1664 } 1657 1665 x25_neigh_put(nb); ··· 1711 1711 rc = x25_route_ioctl(cmd, argp); 1712 1712 break; 1713 1713 case SIOCX25GSUBSCRIP: 1714 - lock_kernel(); 1715 1714 rc = compat_x25_subscr_ioctl(cmd, argp); 1716 - unlock_kernel(); 1717 1715 break; 1718 1716 case SIOCX25SSUBSCRIP: 1719 1717 rc = -EPERM; 1720 1718 if (!capable(CAP_NET_ADMIN)) 1721 1719 break; 1722 - lock_kernel(); 1723 1720 rc = compat_x25_subscr_ioctl(cmd, argp); 1724 - unlock_kernel(); 1725 1721 break; 1726 1722 case SIOCX25GFACILITIES: 1727 1723 case SIOCX25SFACILITIES:
+6 -2
net/x25/x25_link.c
··· 31 31 #include <linux/init.h> 32 32 #include <net/x25.h> 33 33 34 - static LIST_HEAD(x25_neigh_list); 35 - static DEFINE_RWLOCK(x25_neigh_list_lock); 34 + LIST_HEAD(x25_neigh_list); 35 + DEFINE_RWLOCK(x25_neigh_list_lock); 36 36 37 37 static void x25_t20timer_expiry(unsigned long); 38 38 ··· 360 360 dev_put(dev); 361 361 362 362 if (cmd == SIOCX25GSUBSCRIP) { 363 + read_lock_bh(&x25_neigh_list_lock); 363 364 x25_subscr.extended = nb->extended; 364 365 x25_subscr.global_facil_mask = nb->global_facil_mask; 366 + read_unlock_bh(&x25_neigh_list_lock); 365 367 rc = copy_to_user(arg, &x25_subscr, 366 368 sizeof(x25_subscr)) ? -EFAULT : 0; 367 369 } else { 368 370 rc = -EINVAL; 369 371 if (!(x25_subscr.extended && x25_subscr.extended != 1)) { 370 372 rc = 0; 373 + write_lock_bh(&x25_neigh_list_lock); 371 374 nb->extended = x25_subscr.extended; 372 375 nb->global_facil_mask = x25_subscr.global_facil_mask; 376 + write_unlock_bh(&x25_neigh_list_lock); 373 377 } 374 378 } 375 379 x25_neigh_put(nb);