diff -urN linux-2.4.0-test2.orig/include/linux/net.h linux/include/linux/net.h --- linux-2.4.0-test2.orig/include/linux/net.h Sat Jun 24 06:30:21 2000 +++ linux/include/linux/net.h Thu Jul 6 15:21:07 2000 @@ -130,7 +130,7 @@ extern int sock_wake_async(struct socket *sk, int how, int band); extern int sock_register(struct net_proto_family *fam); extern int sock_unregister(int family); -extern struct socket *sock_alloc(void); +extern struct socket *sock_alloc(unsigned char domain); extern int sock_create(int family, int type, int proto, struct socket **); extern void sock_release(struct socket *); extern int sock_sendmsg(struct socket *, struct msghdr *m, int len); diff -urN linux-2.4.0-test2.orig/net/ipv6/icmp.c linux/net/ipv6/icmp.c --- linux-2.4.0-test2.orig/net/ipv6/icmp.c Mon Mar 27 20:35:57 2000 +++ linux/net/ipv6/icmp.c Thu Jul 6 15:17:33 2000 @@ -639,7 +639,7 @@ struct sock *sk; int err; - icmpv6_socket = sock_alloc(); + icmpv6_socket = sock_alloc(PF_INET6); if (icmpv6_socket == NULL) { printk(KERN_ERR "Failed to create the ICMP6 control socket.\n"); diff -urN linux-2.4.0-test2.orig/net/ipv6/mcast.c linux/net/ipv6/mcast.c --- linux-2.4.0-test2.orig/net/ipv6/mcast.c Thu Jun 22 16:23:26 2000 +++ linux/net/ipv6/mcast.c Thu Jul 6 15:14:03 2000 @@ -735,7 +735,7 @@ struct sock *sk; int err; - igmp6_socket = sock_alloc(); + igmp6_socket = sock_alloc(PF_INET6); if (igmp6_socket == NULL) { printk(KERN_ERR "Failed to create the IGMP6 control socket.\n"); diff -urN linux-2.4.0-test2.orig/net/ipv6/ndisc.c linux/net/ipv6/ndisc.c --- linux-2.4.0-test2.orig/net/ipv6/ndisc.c Fri Jan 14 20:25:21 2000 +++ linux/net/ipv6/ndisc.c Thu Jul 6 15:13:37 2000 @@ -1204,7 +1204,7 @@ struct sock *sk; int err; - ndisc_socket = sock_alloc(); + ndisc_socket = sock_alloc(PF_INET6); if (ndisc_socket == NULL) { printk(KERN_ERR "Failed to create the NDISC control socket.\n"); diff -urN linux-2.4.0-test2.orig/net/khttpd/accept.c linux/net/khttpd/accept.c --- linux-2.4.0-test2.orig/net/khttpd/accept.c Sat Jan 22 20:54:58 2000 +++ linux/net/khttpd/accept.c Thu Jul 6 15:16:26 2000 @@ -71,7 +71,7 @@ error = 0; while (error>=0) { - NewSock = sock_alloc(); + NewSock = sock_alloc(PF_INET); if (NewSock==NULL) break; diff -urN linux-2.4.0-test2.orig/net/netlink/af_netlink.c linux/net/netlink/af_netlink.c --- linux-2.4.0-test2.orig/net/netlink/af_netlink.c Mon Apr 24 22:43:05 2000 +++ linux/net/netlink/af_netlink.c Thu Jul 6 15:15:39 2000 @@ -692,7 +692,7 @@ if (unit<0 || unit>=MAX_LINKS) return NULL; - if (!(sock = sock_alloc())) + if (!(sock = sock_alloc(PF_NETLINK))) return NULL; sock->type = SOCK_RAW; diff -urN linux-2.4.0-test2.orig/net/socket.c linux/net/socket.c --- linux-2.4.0-test2.orig/net/socket.c Wed Jun 21 19:10:02 2000 +++ linux/net/socket.c Thu Jul 6 15:11:32 2000 @@ -376,7 +376,7 @@ * NULL is returned. */ -struct socket *sock_alloc(void) +struct socket *sock_alloc(unsigned char domain) { struct inode * inode; struct socket * sock; @@ -389,9 +389,16 @@ inode->i_mode = S_IFSOCK|S_IRWXUGO; inode->i_sock = 1; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + if ((domain & PF_LOCAL) || + (domain & PF_UNIX)) { + inode->i_uid = current->fsuid; + inode->i_gid = current->fsgid; + } else { + inode->i_uid = current->uid; + inode->i_gid = current->gid; + } + sock->inode = inode; init_waitqueue_head(&sock->wait); sock->fasync_list = NULL; @@ -808,7 +815,7 @@ * default. */ - if (!(sock = sock_alloc())) + if (!(sock = sock_alloc(family))) { printk(KERN_WARNING "socket: no more sockets\n"); i = -ENFILE; /* Not exactly a match, but its the @@ -987,7 +994,10 @@ goto out; err = -EMFILE; - if (!(newsock = sock_alloc())) + if (!(sock->sk)) + goto out_put; + + if (!(newsock = sock_alloc(sock->sk->family))) goto out_put; newsock->type = sock->type; diff -urN linux-2.4.0-test2.orig/net/sunrpc/svcsock.c linux/net/sunrpc/svcsock.c --- linux-2.4.0-test2.orig/net/sunrpc/svcsock.c Wed Jun 21 21:43:37 2000 +++ linux/net/sunrpc/svcsock.c Thu Jul 6 15:15:03 2000 @@ -520,7 +520,7 @@ if (!sock) return; - if (!(newsock = sock_alloc())) { + if (!(newsock = sock_alloc(PF_INET))) { printk(KERN_WARNING "%s: no more sockets!\n", serv->sv_name); return; }