Commit 5595a1a5 authored by andrew hendry's avatar andrew hendry Committed by David S. Miller

X25 remove bkl in subscription ioctls

Signed-off-by: default avatarAndrew Hendry <andrew.hendry@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5892b9e9
...@@ -315,6 +315,8 @@ extern struct list_head x25_route_list; ...@@ -315,6 +315,8 @@ extern struct list_head x25_route_list;
extern rwlock_t x25_route_list_lock; extern rwlock_t x25_route_list_lock;
extern struct list_head x25_forward_list; extern struct list_head x25_forward_list;
extern rwlock_t x25_forward_list_lock; extern rwlock_t x25_forward_list_lock;
extern struct list_head x25_neigh_list;
extern rwlock_t x25_neigh_list_lock;
extern int x25_proc_init(void); extern int x25_proc_init(void);
extern void x25_proc_exit(void); extern void x25_proc_exit(void);
......
...@@ -1415,17 +1415,13 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1415,17 +1415,13 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
rc = x25_route_ioctl(cmd, argp); rc = x25_route_ioctl(cmd, argp);
break; break;
case SIOCX25GSUBSCRIP: case SIOCX25GSUBSCRIP:
lock_kernel();
rc = x25_subscr_ioctl(cmd, argp); rc = x25_subscr_ioctl(cmd, argp);
unlock_kernel();
break; break;
case SIOCX25SSUBSCRIP: case SIOCX25SSUBSCRIP:
rc = -EPERM; rc = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
break; break;
lock_kernel();
rc = x25_subscr_ioctl(cmd, argp); rc = x25_subscr_ioctl(cmd, argp);
unlock_kernel();
break; break;
case SIOCX25GFACILITIES: { case SIOCX25GFACILITIES: {
struct x25_facilities fac = x25->facilities; struct x25_facilities fac = x25->facilities;
...@@ -1646,16 +1642,20 @@ static int compat_x25_subscr_ioctl(unsigned int cmd, ...@@ -1646,16 +1642,20 @@ static int compat_x25_subscr_ioctl(unsigned int cmd,
dev_put(dev); dev_put(dev);
if (cmd == SIOCX25GSUBSCRIP) { if (cmd == SIOCX25GSUBSCRIP) {
read_lock_bh(&x25_neigh_list_lock);
x25_subscr.extended = nb->extended; x25_subscr.extended = nb->extended;
x25_subscr.global_facil_mask = nb->global_facil_mask; x25_subscr.global_facil_mask = nb->global_facil_mask;
read_unlock_bh(&x25_neigh_list_lock);
rc = copy_to_user(x25_subscr32, &x25_subscr, rc = copy_to_user(x25_subscr32, &x25_subscr,
sizeof(*x25_subscr32)) ? -EFAULT : 0; sizeof(*x25_subscr32)) ? -EFAULT : 0;
} else { } else {
rc = -EINVAL; rc = -EINVAL;
if (x25_subscr.extended == 0 || x25_subscr.extended == 1) { if (x25_subscr.extended == 0 || x25_subscr.extended == 1) {
rc = 0; rc = 0;
write_lock_bh(&x25_neigh_list_lock);
nb->extended = x25_subscr.extended; nb->extended = x25_subscr.extended;
nb->global_facil_mask = x25_subscr.global_facil_mask; nb->global_facil_mask = x25_subscr.global_facil_mask;
write_unlock_bh(&x25_neigh_list_lock);
} }
} }
x25_neigh_put(nb); x25_neigh_put(nb);
...@@ -1711,17 +1711,13 @@ static int compat_x25_ioctl(struct socket *sock, unsigned int cmd, ...@@ -1711,17 +1711,13 @@ static int compat_x25_ioctl(struct socket *sock, unsigned int cmd,
rc = x25_route_ioctl(cmd, argp); rc = x25_route_ioctl(cmd, argp);
break; break;
case SIOCX25GSUBSCRIP: case SIOCX25GSUBSCRIP:
lock_kernel();
rc = compat_x25_subscr_ioctl(cmd, argp); rc = compat_x25_subscr_ioctl(cmd, argp);
unlock_kernel();
break; break;
case SIOCX25SSUBSCRIP: case SIOCX25SSUBSCRIP:
rc = -EPERM; rc = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
break; break;
lock_kernel();
rc = compat_x25_subscr_ioctl(cmd, argp); rc = compat_x25_subscr_ioctl(cmd, argp);
unlock_kernel();
break; break;
case SIOCX25GFACILITIES: case SIOCX25GFACILITIES:
case SIOCX25SFACILITIES: case SIOCX25SFACILITIES:
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include <linux/init.h> #include <linux/init.h>
#include <net/x25.h> #include <net/x25.h>
static LIST_HEAD(x25_neigh_list); LIST_HEAD(x25_neigh_list);
static DEFINE_RWLOCK(x25_neigh_list_lock); DEFINE_RWLOCK(x25_neigh_list_lock);
static void x25_t20timer_expiry(unsigned long); static void x25_t20timer_expiry(unsigned long);
...@@ -360,16 +360,20 @@ int x25_subscr_ioctl(unsigned int cmd, void __user *arg) ...@@ -360,16 +360,20 @@ int x25_subscr_ioctl(unsigned int cmd, void __user *arg)
dev_put(dev); dev_put(dev);
if (cmd == SIOCX25GSUBSCRIP) { if (cmd == SIOCX25GSUBSCRIP) {
read_lock_bh(&x25_neigh_list_lock);
x25_subscr.extended = nb->extended; x25_subscr.extended = nb->extended;
x25_subscr.global_facil_mask = nb->global_facil_mask; x25_subscr.global_facil_mask = nb->global_facil_mask;
read_unlock_bh(&x25_neigh_list_lock);
rc = copy_to_user(arg, &x25_subscr, rc = copy_to_user(arg, &x25_subscr,
sizeof(x25_subscr)) ? -EFAULT : 0; sizeof(x25_subscr)) ? -EFAULT : 0;
} else { } else {
rc = -EINVAL; rc = -EINVAL;
if (!(x25_subscr.extended && x25_subscr.extended != 1)) { if (!(x25_subscr.extended && x25_subscr.extended != 1)) {
rc = 0; rc = 0;
write_lock_bh(&x25_neigh_list_lock);
nb->extended = x25_subscr.extended; nb->extended = x25_subscr.extended;
nb->global_facil_mask = x25_subscr.global_facil_mask; nb->global_facil_mask = x25_subscr.global_facil_mask;
write_unlock_bh(&x25_neigh_list_lock);
} }
} }
x25_neigh_put(nb); x25_neigh_put(nb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment