aboutsummaryrefslogtreecommitdiffstats
path: root/net/netrom/af_netrom.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/netrom/af_netrom.c')
-rw-r--r--net/netrom/af_netrom.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index e5d82d711cae..d44981f5a619 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -11,6 +11,7 @@
11#include <linux/config.h> 11#include <linux/config.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/moduleparam.h> 13#include <linux/moduleparam.h>
14#include <linux/capability.h>
14#include <linux/errno.h> 15#include <linux/errno.h>
15#include <linux/types.h> 16#include <linux/types.h>
16#include <linux/socket.h> 17#include <linux/socket.h>
@@ -63,7 +64,7 @@ static unsigned short circuit = 0x101;
63static HLIST_HEAD(nr_list); 64static HLIST_HEAD(nr_list);
64static DEFINE_SPINLOCK(nr_list_lock); 65static DEFINE_SPINLOCK(nr_list_lock);
65 66
66static struct proto_ops nr_proto_ops; 67static const struct proto_ops nr_proto_ops;
67 68
68/* 69/*
69 * Socket removal during an interrupt is now safe. 70 * Socket removal during an interrupt is now safe.
@@ -1166,10 +1167,11 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1166 void __user *argp = (void __user *)arg; 1167 void __user *argp = (void __user *)arg;
1167 int ret; 1168 int ret;
1168 1169
1169 lock_sock(sk);
1170 switch (cmd) { 1170 switch (cmd) {
1171 case TIOCOUTQ: { 1171 case TIOCOUTQ: {
1172 long amount; 1172 long amount;
1173
1174 lock_sock(sk);
1173 amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); 1175 amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
1174 if (amount < 0) 1176 if (amount < 0)
1175 amount = 0; 1177 amount = 0;
@@ -1180,6 +1182,8 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1180 case TIOCINQ: { 1182 case TIOCINQ: {
1181 struct sk_buff *skb; 1183 struct sk_buff *skb;
1182 long amount = 0L; 1184 long amount = 0L;
1185
1186 lock_sock(sk);
1183 /* These two are safe on a single CPU system as only user tasks fiddle here */ 1187 /* These two are safe on a single CPU system as only user tasks fiddle here */
1184 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) 1188 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
1185 amount = skb->len; 1189 amount = skb->len;
@@ -1188,6 +1192,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1188 } 1192 }
1189 1193
1190 case SIOCGSTAMP: 1194 case SIOCGSTAMP:
1195 lock_sock(sk);
1191 ret = sock_get_timestamp(sk, argp); 1196 ret = sock_get_timestamp(sk, argp);
1192 release_sock(sk); 1197 release_sock(sk);
1193 return ret; 1198 return ret;
@@ -1202,21 +1207,17 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1202 case SIOCSIFNETMASK: 1207 case SIOCSIFNETMASK:
1203 case SIOCGIFMETRIC: 1208 case SIOCGIFMETRIC:
1204 case SIOCSIFMETRIC: 1209 case SIOCSIFMETRIC:
1205 release_sock(sk);
1206 return -EINVAL; 1210 return -EINVAL;
1207 1211
1208 case SIOCADDRT: 1212 case SIOCADDRT:
1209 case SIOCDELRT: 1213 case SIOCDELRT:
1210 case SIOCNRDECOBS: 1214 case SIOCNRDECOBS:
1211 release_sock(sk);
1212 if (!capable(CAP_NET_ADMIN)) return -EPERM; 1215 if (!capable(CAP_NET_ADMIN)) return -EPERM;
1213 return nr_rt_ioctl(cmd, argp); 1216 return nr_rt_ioctl(cmd, argp);
1214 1217
1215 default: 1218 default:
1216 release_sock(sk); 1219 return -ENOIOCTLCMD;
1217 return dev_ioctl(cmd, argp);
1218 } 1220 }
1219 release_sock(sk);
1220 1221
1221 return 0; 1222 return 0;
1222} 1223}
@@ -1337,7 +1338,7 @@ static struct net_proto_family nr_family_ops = {
1337 .owner = THIS_MODULE, 1338 .owner = THIS_MODULE,
1338}; 1339};
1339 1340
1340static struct proto_ops nr_proto_ops = { 1341static const struct proto_ops nr_proto_ops = {
1341 .family = PF_NETROM, 1342 .family = PF_NETROM,
1342 .owner = THIS_MODULE, 1343 .owner = THIS_MODULE,
1343 .release = nr_release, 1344 .release = nr_release,