]> err.no Git - linux-2.6/blobdiff - net/socket.c
[NETFILTER]: CLUSTERIP: fix memcpy() length typo
[linux-2.6] / net / socket.c
index 2cd44990d8d3daa6ce0495422549ea4745a56e1b..94fe638b4d72b3721cbda637573c7182f5535b32 100644 (file)
@@ -4,7 +4,7 @@
  * Version:    @(#)socket.c    1.1.93  18/02/95
  *
  * Authors:    Orest Zborowski, <obz@Kodak.COM>
- *             Ross Biro, <bir7@leland.Stanford.Edu>
+ *             Ross Biro
  *             Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  *
  * Fixes:
@@ -70,6 +70,8 @@
 #include <linux/seq_file.h>
 #include <linux/wanrouter.h>
 #include <linux/if_bridge.h>
+#include <linux/if_frad.h>
+#include <linux/if_vlan.h>
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/cache.h>
@@ -81,6 +83,7 @@
 #include <linux/syscalls.h>
 #include <linux/compat.h>
 #include <linux/kmod.h>
+#include <linux/audit.h>
 
 #ifdef CONFIG_NET_RADIO
 #include <linux/wireless.h>            /* Note : will define WIRELESS_EXT */
@@ -226,7 +229,7 @@ int move_addr_to_kernel(void __user *uaddr, int ulen, void *kaddr)
                return 0;
        if(copy_from_user(kaddr,uaddr,ulen))
                return -EFAULT;
-       return 0;
+       return audit_sockaddr(ulen, kaddr);
 }
 
 /**
@@ -271,7 +274,7 @@ int move_addr_to_user(void *kaddr, int klen, void __user *uaddr, int __user *ule
 
 #define SOCKFS_MAGIC 0x534F434B
 
-static kmem_cache_t * sock_inode_cachep;
+static kmem_cache_t * sock_inode_cachep __read_mostly;
 
 static struct inode *sock_alloc_inode(struct super_block *sb)
 {
@@ -330,7 +333,7 @@ static struct super_block *sockfs_get_sb(struct file_system_type *fs_type,
        return get_sb_pseudo(fs_type, "socket:", &sockfs_ops, SOCKFS_MAGIC);
 }
 
-static struct vfsmount *sock_mnt;
+static struct vfsmount *sock_mnt __read_mostly;
 
 static struct file_system_type sock_fs_type = {
        .name =         "sockfs",
@@ -382,9 +385,8 @@ int sock_map_fd(struct socket *sock)
                        goto out;
                }
 
-               sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
+               this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
                this.name = name;
-               this.len = strlen(name);
                this.hash = SOCK_INODE(sock)->i_ino;
 
                file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
@@ -404,6 +406,7 @@ int sock_map_fd(struct socket *sock)
                file->f_mode = FMODE_READ | FMODE_WRITE;
                file->f_flags = O_RDWR;
                file->f_pos = 0;
+               file->private_data = sock;
                fd_install(fd, file);
        }
 
@@ -436,6 +439,9 @@ struct socket *sockfd_lookup(int fd, int *err)
                return NULL;
        }
 
+       if (file->f_op == &socket_file_ops)
+               return file->private_data;      /* set in sock_map_fd */
+
        inode = file->f_dentry->d_inode;
        if (!S_ISSOCK(inode->i_mode)) {
                *err = -ENOTSOCK;
@@ -720,8 +726,8 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf,
        return __sock_sendmsg(iocb, sock, &x->async_msg, size);
 }
 
-ssize_t sock_sendpage(struct file *file, struct page *page,
-                     int offset, size_t size, loff_t *ppos, int more)
+static ssize_t sock_sendpage(struct file *file, struct page *page,
+                            int offset, size_t size, loff_t *ppos, int more)
 {
        struct socket *sock;
        int flags;
@@ -944,7 +950,7 @@ static int sock_mmap(struct file * file, struct vm_area_struct * vma)
        return sock->ops->mmap(file, sock, vma);
 }
 
-int sock_close(struct inode *inode, struct file *filp)
+static int sock_close(struct inode *inode, struct file *filp)
 {
        /*
         *      It was possible the inode is NULL we were 
@@ -1906,7 +1912,11 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
        /* copy_from_user should be SMP safe. */
        if (copy_from_user(a, args, nargs[call]))
                return -EFAULT;
-               
+
+       err = audit_socketcall(nargs[call]/sizeof(unsigned long), a);
+       if (err)
+               return err;
+
        a0=a[0];
        a1=a[1];
        
@@ -2019,9 +2029,6 @@ int sock_unregister(int family)
        return 0;
 }
 
-
-extern void sk_init(void);
-
 void __init sock_init(void)
 {
        /*