vserver 1.9.5.x5
[linux-2.6.git] / net / ax25 / af_ax25.c
index 75ab89d..974d029 100644 (file)
@@ -52,7 +52,7 @@
 
 
 HLIST_HEAD(ax25_list);
-spinlock_t ax25_list_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(ax25_list_lock);
 
 static struct proto_ops ax25_proto_ops;
 
@@ -336,7 +336,7 @@ void ax25_destroy_socket(ax25_cb *ax25)
  *               includes a KILL command to abort any connection.
  *               VERY useful for debugging ;-)
  */
-static int ax25_ctl_ioctl(const unsigned int cmd, void *arg)
+static int ax25_ctl_ioctl(const unsigned int cmd, void __user *arg)
 {
        struct ax25_ctl_struct ax25_ctl;
        ax25_digi digi;
@@ -508,7 +508,7 @@ ax25_cb *ax25_create_cb(void)
  */
 
 static int ax25_setsockopt(struct socket *sock, int level, int optname,
-       char *optval, int optlen)
+       char __user *optval, int optlen)
 {
        struct sock *sk = sock->sk;
        ax25_cb *ax25;
@@ -522,7 +522,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
        if (optlen < sizeof(int))
                return -EINVAL;
 
-       if (get_user(opt, (int *)optval))
+       if (get_user(opt, (int __user *)optval))
                return -EFAULT;
 
        lock_sock(sk);
@@ -648,7 +648,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
 }
 
 static int ax25_getsockopt(struct socket *sock, int level, int optname,
-       char *optval, int *optlen)
+       char __user *optval, int __user *optlen)
 {
        struct sock *sk = sock->sk;
        ax25_cb *ax25;
@@ -763,7 +763,7 @@ out:
        return res;
 }
 
-int ax25_create(struct socket *sock, int protocol)
+static int ax25_create(struct socket *sock, int protocol)
 {
        struct sock *sk;
        ax25_cb *ax25;
@@ -1176,13 +1176,16 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
                /* check if we can remove this feature. It is broken. */
                printk(KERN_WARNING "ax25_connect(): %s uses autobind, please contact jreuter@yaina.de\n",
                        current->comm);
-               if ((err = ax25_rt_autobind(ax25, &fsa->fsa_ax25.sax25_call)) < 0)
+               if ((err = ax25_rt_autobind(ax25, &fsa->fsa_ax25.sax25_call)) < 0) {
+                       kfree(digi);
                        goto out;
+               }
 
                ax25_fillin_cb(ax25, ax25->ax25_dev);
                ax25_cb_add(ax25);
        } else {
                if (ax25->ax25_dev == NULL) {
+                       kfree(digi);
                        err = -EHOSTUNREACH;
                        goto out;
                }
@@ -1191,8 +1194,7 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
        if (sk->sk_type == SOCK_SEQPACKET &&
            (ax25t=ax25_find_cb(&ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi,
                         ax25->ax25_dev->dev))) {
-               if (digi != NULL)
-                       kfree(digi);
+               kfree(digi);
                err = -EADDRINUSE;              /* Already such a connection */
                ax25_cb_put(ax25t);
                goto out;
@@ -1336,7 +1338,6 @@ static int ax25_accept(struct socket *sock, struct socket *newsock, int flags)
        remove_wait_queue(sk->sk_sleep, &wait);
 
        newsk            = skb->sk;
-       newsk->sk_pair   = NULL;
        newsk->sk_socket = newsock;
        newsk->sk_sleep  = &newsock->wait;
 
@@ -1413,9 +1414,8 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
        size_t size;
        int lv, err, addr_len = msg->msg_namelen;
 
-       if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR)) {
+       if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_CMSG_COMPAT))
                return -EINVAL;
-       }
 
        lock_sock(sk);
        ax25 = ax25_sk(sk);
@@ -1669,6 +1669,7 @@ static int ax25_shutdown(struct socket *sk, int how)
 static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
        struct sock *sk = sock->sk;
+       void __user *argp = (void __user *)arg;
        int res = 0;
 
        lock_sock(sk);
@@ -1678,7 +1679,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
                if (amount < 0)
                        amount = 0;
-               res = put_user(amount, (int *)arg);
+               res = put_user(amount, (int __user *)argp);
                break;
        }
 
@@ -1688,13 +1689,13 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                /* These two are safe on a single CPU system as only user tasks fiddle here */
                if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
                        amount = skb->len;
-               res = put_user(amount, (int *)arg);
+               res = put_user(amount, (int __user *)argp);
                break;
        }
 
        case SIOCGSTAMP:
                if (sk != NULL) {
-                       res = sock_get_timestamp(sk, (struct timeval *)arg);
+                       res = sock_get_timestamp(sk, argp);
                        break;
                }
                res = -EINVAL;
@@ -1704,7 +1705,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        case SIOCAX25DELUID:    /* Delete a uid from the uid/call map table */
        case SIOCAX25GETUID: {
                struct sockaddr_ax25 sax25;
-               if (copy_from_user(&sax25, (void *)arg, sizeof(sax25))) {
+               if (copy_from_user(&sax25, argp, sizeof(sax25))) {
                        res = -EFAULT;
                        break;
                }
@@ -1718,7 +1719,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        res = -EPERM;
                        break;
                }
-               if (get_user(amount, (long *)arg)) {
+               if (get_user(amount, (long __user *)argp)) {
                        res = -EFAULT;
                        break;
                }
@@ -1738,7 +1739,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        res = -EPERM;
                        break;
                }
-               res = ax25_rt_ioctl(cmd, (void *)arg);
+               res = ax25_rt_ioctl(cmd, argp);
                break;
 
        case SIOCAX25CTLCON:
@@ -1746,7 +1747,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        res = -EPERM;
                        break;
                }
-               res = ax25_ctl_ioctl(cmd, (void *)arg);
+               res = ax25_ctl_ioctl(cmd, argp);
                break;
 
        case SIOCAX25GETINFO:
@@ -1783,12 +1784,12 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                                warned=1;
                        }
 
-                       if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_deprecated))) {
+                       if (copy_to_user(argp, &ax25_info, sizeof(struct ax25_info_struct_deprecated))) {
                                res = -EFAULT;
                                break;
                        }
                } else {
-                       if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct))) {
+                       if (copy_to_user(argp, &ax25_info, sizeof(struct ax25_info_struct))) {
                                res = -EINVAL;
                                break;
                        }
@@ -1804,7 +1805,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        res = -EPERM;
                        break;
                }
-               if (copy_from_user(&ax25_fwd, (void *)arg, sizeof(ax25_fwd))) {
+               if (copy_from_user(&ax25_fwd, argp, sizeof(ax25_fwd))) {
                        res = -EFAULT;
                        break;
                }
@@ -1826,7 +1827,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                break;
 
        default:
-               res = dev_ioctl(cmd, (void *)arg);
+               res = dev_ioctl(cmd, argp);
                break;
        }
        release_sock(sk);