diff options
Diffstat (limited to 'net/unix')
-rw-r--r-- | net/unix/af_unix.c | 215 | ||||
-rw-r--r-- | net/unix/garbage.c | 12 | ||||
-rw-r--r-- | net/unix/sysctl_net_unix.c | 3 |
3 files changed, 116 insertions, 114 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 66d5ac4773ab..d1b89820ab4f 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -164,7 +164,7 @@ static inline int unix_our_peer(struct sock *sk, struct sock *osk) | |||
164 | 164 | ||
165 | static inline int unix_may_send(struct sock *sk, struct sock *osk) | 165 | static inline int unix_may_send(struct sock *sk, struct sock *osk) |
166 | { | 166 | { |
167 | return (unix_peer(osk) == NULL || unix_our_peer(sk, osk)); | 167 | return unix_peer(osk) == NULL || unix_our_peer(sk, osk); |
168 | } | 168 | } |
169 | 169 | ||
170 | static inline int unix_recvq_full(struct sock const *sk) | 170 | static inline int unix_recvq_full(struct sock const *sk) |
@@ -197,7 +197,7 @@ static inline void unix_release_addr(struct unix_address *addr) | |||
197 | * - if started by zero, it is abstract name. | 197 | * - if started by zero, it is abstract name. |
198 | */ | 198 | */ |
199 | 199 | ||
200 | static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp) | 200 | static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned *hashp) |
201 | { | 201 | { |
202 | if (len <= sizeof(short) || len > sizeof(*sunaddr)) | 202 | if (len <= sizeof(short) || len > sizeof(*sunaddr)) |
203 | return -EINVAL; | 203 | return -EINVAL; |
@@ -211,12 +211,12 @@ static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp) | |||
211 | * we are guaranteed that it is a valid memory location in our | 211 | * we are guaranteed that it is a valid memory location in our |
212 | * kernel address buffer. | 212 | * kernel address buffer. |
213 | */ | 213 | */ |
214 | ((char *)sunaddr)[len]=0; | 214 | ((char *)sunaddr)[len] = 0; |
215 | len = strlen(sunaddr->sun_path)+1+sizeof(short); | 215 | len = strlen(sunaddr->sun_path)+1+sizeof(short); |
216 | return len; | 216 | return len; |
217 | } | 217 | } |
218 | 218 | ||
219 | *hashp = unix_hash_fold(csum_partial((char*)sunaddr, len, 0)); | 219 | *hashp = unix_hash_fold(csum_partial(sunaddr, len, 0)); |
220 | return len; | 220 | return len; |
221 | } | 221 | } |
222 | 222 | ||
@@ -295,8 +295,7 @@ static struct sock *unix_find_socket_byinode(struct net *net, struct inode *i) | |||
295 | if (!net_eq(sock_net(s), net)) | 295 | if (!net_eq(sock_net(s), net)) |
296 | continue; | 296 | continue; |
297 | 297 | ||
298 | if(dentry && dentry->d_inode == i) | 298 | if (dentry && dentry->d_inode == i) { |
299 | { | ||
300 | sock_hold(s); | 299 | sock_hold(s); |
301 | goto found; | 300 | goto found; |
302 | } | 301 | } |
@@ -354,7 +353,7 @@ static void unix_sock_destructor(struct sock *sk) | |||
354 | WARN_ON(!sk_unhashed(sk)); | 353 | WARN_ON(!sk_unhashed(sk)); |
355 | WARN_ON(sk->sk_socket); | 354 | WARN_ON(sk->sk_socket); |
356 | if (!sock_flag(sk, SOCK_DEAD)) { | 355 | if (!sock_flag(sk, SOCK_DEAD)) { |
357 | printk("Attempt to release alive unix socket: %p\n", sk); | 356 | printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk); |
358 | return; | 357 | return; |
359 | } | 358 | } |
360 | 359 | ||
@@ -362,12 +361,16 @@ static void unix_sock_destructor(struct sock *sk) | |||
362 | unix_release_addr(u->addr); | 361 | unix_release_addr(u->addr); |
363 | 362 | ||
364 | atomic_dec(&unix_nr_socks); | 363 | atomic_dec(&unix_nr_socks); |
364 | local_bh_disable(); | ||
365 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); | ||
366 | local_bh_enable(); | ||
365 | #ifdef UNIX_REFCNT_DEBUG | 367 | #ifdef UNIX_REFCNT_DEBUG |
366 | printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk, atomic_read(&unix_nr_socks)); | 368 | printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk, |
369 | atomic_read(&unix_nr_socks)); | ||
367 | #endif | 370 | #endif |
368 | } | 371 | } |
369 | 372 | ||
370 | static int unix_release_sock (struct sock *sk, int embrion) | 373 | static int unix_release_sock(struct sock *sk, int embrion) |
371 | { | 374 | { |
372 | struct unix_sock *u = unix_sk(sk); | 375 | struct unix_sock *u = unix_sk(sk); |
373 | struct dentry *dentry; | 376 | struct dentry *dentry; |
@@ -392,9 +395,9 @@ static int unix_release_sock (struct sock *sk, int embrion) | |||
392 | 395 | ||
393 | wake_up_interruptible_all(&u->peer_wait); | 396 | wake_up_interruptible_all(&u->peer_wait); |
394 | 397 | ||
395 | skpair=unix_peer(sk); | 398 | skpair = unix_peer(sk); |
396 | 399 | ||
397 | if (skpair!=NULL) { | 400 | if (skpair != NULL) { |
398 | if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { | 401 | if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { |
399 | unix_state_lock(skpair); | 402 | unix_state_lock(skpair); |
400 | /* No more writes */ | 403 | /* No more writes */ |
@@ -414,7 +417,7 @@ static int unix_release_sock (struct sock *sk, int embrion) | |||
414 | /* Try to flush out this socket. Throw out buffers at least */ | 417 | /* Try to flush out this socket. Throw out buffers at least */ |
415 | 418 | ||
416 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { | 419 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { |
417 | if (state==TCP_LISTEN) | 420 | if (state == TCP_LISTEN) |
418 | unix_release_sock(skb->sk, 1); | 421 | unix_release_sock(skb->sk, 1); |
419 | /* passed fds are erased in the kfree_skb hook */ | 422 | /* passed fds are erased in the kfree_skb hook */ |
420 | kfree_skb(skb); | 423 | kfree_skb(skb); |
@@ -453,11 +456,11 @@ static int unix_listen(struct socket *sock, int backlog) | |||
453 | struct unix_sock *u = unix_sk(sk); | 456 | struct unix_sock *u = unix_sk(sk); |
454 | 457 | ||
455 | err = -EOPNOTSUPP; | 458 | err = -EOPNOTSUPP; |
456 | if (sock->type!=SOCK_STREAM && sock->type!=SOCK_SEQPACKET) | 459 | if (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET) |
457 | goto out; /* Only stream/seqpacket sockets accept */ | 460 | goto out; /* Only stream/seqpacket sockets accept */ |
458 | err = -EINVAL; | 461 | err = -EINVAL; |
459 | if (!u->addr) | 462 | if (!u->addr) |
460 | goto out; /* No listens on an unbound socket */ | 463 | goto out; /* No listens on an unbound socket */ |
461 | unix_state_lock(sk); | 464 | unix_state_lock(sk); |
462 | if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN) | 465 | if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN) |
463 | goto out_unlock; | 466 | goto out_unlock; |
@@ -467,8 +470,7 @@ static int unix_listen(struct socket *sock, int backlog) | |||
467 | sk->sk_state = TCP_LISTEN; | 470 | sk->sk_state = TCP_LISTEN; |
468 | /* set credentials so connect can copy them */ | 471 | /* set credentials so connect can copy them */ |
469 | sk->sk_peercred.pid = task_tgid_vnr(current); | 472 | sk->sk_peercred.pid = task_tgid_vnr(current); |
470 | sk->sk_peercred.uid = current->euid; | 473 | current_euid_egid(&sk->sk_peercred.uid, &sk->sk_peercred.gid); |
471 | sk->sk_peercred.gid = current->egid; | ||
472 | err = 0; | 474 | err = 0; |
473 | 475 | ||
474 | out_unlock: | 476 | out_unlock: |
@@ -566,9 +568,9 @@ static const struct proto_ops unix_seqpacket_ops = { | |||
566 | }; | 568 | }; |
567 | 569 | ||
568 | static struct proto unix_proto = { | 570 | static struct proto unix_proto = { |
569 | .name = "UNIX", | 571 | .name = "UNIX", |
570 | .owner = THIS_MODULE, | 572 | .owner = THIS_MODULE, |
571 | .obj_size = sizeof(struct unix_sock), | 573 | .obj_size = sizeof(struct unix_sock), |
572 | }; | 574 | }; |
573 | 575 | ||
574 | /* | 576 | /* |
@@ -579,7 +581,7 @@ static struct proto unix_proto = { | |||
579 | */ | 581 | */ |
580 | static struct lock_class_key af_unix_sk_receive_queue_lock_key; | 582 | static struct lock_class_key af_unix_sk_receive_queue_lock_key; |
581 | 583 | ||
582 | static struct sock * unix_create1(struct net *net, struct socket *sock) | 584 | static struct sock *unix_create1(struct net *net, struct socket *sock) |
583 | { | 585 | { |
584 | struct sock *sk = NULL; | 586 | struct sock *sk = NULL; |
585 | struct unix_sock *u; | 587 | struct unix_sock *u; |
@@ -592,7 +594,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock) | |||
592 | if (!sk) | 594 | if (!sk) |
593 | goto out; | 595 | goto out; |
594 | 596 | ||
595 | sock_init_data(sock,sk); | 597 | sock_init_data(sock, sk); |
596 | lockdep_set_class(&sk->sk_receive_queue.lock, | 598 | lockdep_set_class(&sk->sk_receive_queue.lock, |
597 | &af_unix_sk_receive_queue_lock_key); | 599 | &af_unix_sk_receive_queue_lock_key); |
598 | 600 | ||
@@ -611,6 +613,11 @@ static struct sock * unix_create1(struct net *net, struct socket *sock) | |||
611 | out: | 613 | out: |
612 | if (sk == NULL) | 614 | if (sk == NULL) |
613 | atomic_dec(&unix_nr_socks); | 615 | atomic_dec(&unix_nr_socks); |
616 | else { | ||
617 | local_bh_disable(); | ||
618 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | ||
619 | local_bh_enable(); | ||
620 | } | ||
614 | return sk; | 621 | return sk; |
615 | } | 622 | } |
616 | 623 | ||
@@ -630,7 +637,7 @@ static int unix_create(struct net *net, struct socket *sock, int protocol) | |||
630 | * nothing uses it. | 637 | * nothing uses it. |
631 | */ | 638 | */ |
632 | case SOCK_RAW: | 639 | case SOCK_RAW: |
633 | sock->type=SOCK_DGRAM; | 640 | sock->type = SOCK_DGRAM; |
634 | case SOCK_DGRAM: | 641 | case SOCK_DGRAM: |
635 | sock->ops = &unix_dgram_ops; | 642 | sock->ops = &unix_dgram_ops; |
636 | break; | 643 | break; |
@@ -653,7 +660,7 @@ static int unix_release(struct socket *sock) | |||
653 | 660 | ||
654 | sock->sk = NULL; | 661 | sock->sk = NULL; |
655 | 662 | ||
656 | return unix_release_sock (sk, 0); | 663 | return unix_release_sock(sk, 0); |
657 | } | 664 | } |
658 | 665 | ||
659 | static int unix_autobind(struct socket *sock) | 666 | static int unix_autobind(struct socket *sock) |
@@ -662,7 +669,7 @@ static int unix_autobind(struct socket *sock) | |||
662 | struct net *net = sock_net(sk); | 669 | struct net *net = sock_net(sk); |
663 | struct unix_sock *u = unix_sk(sk); | 670 | struct unix_sock *u = unix_sk(sk); |
664 | static u32 ordernum = 1; | 671 | static u32 ordernum = 1; |
665 | struct unix_address * addr; | 672 | struct unix_address *addr; |
666 | int err; | 673 | int err; |
667 | 674 | ||
668 | mutex_lock(&u->readlock); | 675 | mutex_lock(&u->readlock); |
@@ -681,7 +688,7 @@ static int unix_autobind(struct socket *sock) | |||
681 | 688 | ||
682 | retry: | 689 | retry: |
683 | addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short); | 690 | addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short); |
684 | addr->hash = unix_hash_fold(csum_partial((void*)addr->name, addr->len, 0)); | 691 | addr->hash = unix_hash_fold(csum_partial(addr->name, addr->len, 0)); |
685 | 692 | ||
686 | spin_lock(&unix_table_lock); | 693 | spin_lock(&unix_table_lock); |
687 | ordernum = (ordernum+1)&0xFFFFF; | 694 | ordernum = (ordernum+1)&0xFFFFF; |
@@ -736,14 +743,14 @@ static struct sock *unix_find_other(struct net *net, | |||
736 | 743 | ||
737 | path_put(&path); | 744 | path_put(&path); |
738 | 745 | ||
739 | err=-EPROTOTYPE; | 746 | err = -EPROTOTYPE; |
740 | if (u->sk_type != type) { | 747 | if (u->sk_type != type) { |
741 | sock_put(u); | 748 | sock_put(u); |
742 | goto fail; | 749 | goto fail; |
743 | } | 750 | } |
744 | } else { | 751 | } else { |
745 | err = -ECONNREFUSED; | 752 | err = -ECONNREFUSED; |
746 | u=unix_find_socket_byname(net, sunname, len, type, hash); | 753 | u = unix_find_socket_byname(net, sunname, len, type, hash); |
747 | if (u) { | 754 | if (u) { |
748 | struct dentry *dentry; | 755 | struct dentry *dentry; |
749 | dentry = unix_sk(u)->dentry; | 756 | dentry = unix_sk(u)->dentry; |
@@ -757,7 +764,7 @@ static struct sock *unix_find_other(struct net *net, | |||
757 | put_fail: | 764 | put_fail: |
758 | path_put(&path); | 765 | path_put(&path); |
759 | fail: | 766 | fail: |
760 | *error=err; | 767 | *error = err; |
761 | return NULL; | 768 | return NULL; |
762 | } | 769 | } |
763 | 770 | ||
@@ -767,8 +774,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
767 | struct sock *sk = sock->sk; | 774 | struct sock *sk = sock->sk; |
768 | struct net *net = sock_net(sk); | 775 | struct net *net = sock_net(sk); |
769 | struct unix_sock *u = unix_sk(sk); | 776 | struct unix_sock *u = unix_sk(sk); |
770 | struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; | 777 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; |
771 | struct dentry * dentry = NULL; | 778 | struct dentry *dentry = NULL; |
772 | struct nameidata nd; | 779 | struct nameidata nd; |
773 | int err; | 780 | int err; |
774 | unsigned hash; | 781 | unsigned hash; |
@@ -779,7 +786,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
779 | if (sunaddr->sun_family != AF_UNIX) | 786 | if (sunaddr->sun_family != AF_UNIX) |
780 | goto out; | 787 | goto out; |
781 | 788 | ||
782 | if (addr_len==sizeof(short)) { | 789 | if (addr_len == sizeof(short)) { |
783 | err = unix_autobind(sock); | 790 | err = unix_autobind(sock); |
784 | goto out; | 791 | goto out; |
785 | } | 792 | } |
@@ -829,7 +836,11 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
829 | err = mnt_want_write(nd.path.mnt); | 836 | err = mnt_want_write(nd.path.mnt); |
830 | if (err) | 837 | if (err) |
831 | goto out_mknod_dput; | 838 | goto out_mknod_dput; |
839 | err = security_path_mknod(&nd.path, dentry, mode, 0); | ||
840 | if (err) | ||
841 | goto out_mknod_drop_write; | ||
832 | err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0); | 842 | err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0); |
843 | out_mknod_drop_write: | ||
833 | mnt_drop_write(nd.path.mnt); | 844 | mnt_drop_write(nd.path.mnt); |
834 | if (err) | 845 | if (err) |
835 | goto out_mknod_dput; | 846 | goto out_mknod_dput; |
@@ -875,8 +886,8 @@ out_mknod_unlock: | |||
875 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | 886 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); |
876 | path_put(&nd.path); | 887 | path_put(&nd.path); |
877 | out_mknod_parent: | 888 | out_mknod_parent: |
878 | if (err==-EEXIST) | 889 | if (err == -EEXIST) |
879 | err=-EADDRINUSE; | 890 | err = -EADDRINUSE; |
880 | unix_release_addr(addr); | 891 | unix_release_addr(addr); |
881 | goto out_up; | 892 | goto out_up; |
882 | } | 893 | } |
@@ -911,7 +922,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, | |||
911 | { | 922 | { |
912 | struct sock *sk = sock->sk; | 923 | struct sock *sk = sock->sk; |
913 | struct net *net = sock_net(sk); | 924 | struct net *net = sock_net(sk); |
914 | struct sockaddr_un *sunaddr=(struct sockaddr_un*)addr; | 925 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr; |
915 | struct sock *other; | 926 | struct sock *other; |
916 | unsigned hash; | 927 | unsigned hash; |
917 | int err; | 928 | int err; |
@@ -927,7 +938,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, | |||
927 | goto out; | 938 | goto out; |
928 | 939 | ||
929 | restart: | 940 | restart: |
930 | other=unix_find_other(net, sunaddr, alen, sock->type, hash, &err); | 941 | other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err); |
931 | if (!other) | 942 | if (!other) |
932 | goto out; | 943 | goto out; |
933 | 944 | ||
@@ -961,14 +972,14 @@ restart: | |||
961 | */ | 972 | */ |
962 | if (unix_peer(sk)) { | 973 | if (unix_peer(sk)) { |
963 | struct sock *old_peer = unix_peer(sk); | 974 | struct sock *old_peer = unix_peer(sk); |
964 | unix_peer(sk)=other; | 975 | unix_peer(sk) = other; |
965 | unix_state_double_unlock(sk, other); | 976 | unix_state_double_unlock(sk, other); |
966 | 977 | ||
967 | if (other != old_peer) | 978 | if (other != old_peer) |
968 | unix_dgram_disconnected(sk, old_peer); | 979 | unix_dgram_disconnected(sk, old_peer); |
969 | sock_put(old_peer); | 980 | sock_put(old_peer); |
970 | } else { | 981 | } else { |
971 | unix_peer(sk)=other; | 982 | unix_peer(sk) = other; |
972 | unix_state_double_unlock(sk, other); | 983 | unix_state_double_unlock(sk, other); |
973 | } | 984 | } |
974 | return 0; | 985 | return 0; |
@@ -1004,7 +1015,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo) | |||
1004 | static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, | 1015 | static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, |
1005 | int addr_len, int flags) | 1016 | int addr_len, int flags) |
1006 | { | 1017 | { |
1007 | struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; | 1018 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; |
1008 | struct sock *sk = sock->sk; | 1019 | struct sock *sk = sock->sk; |
1009 | struct net *net = sock_net(sk); | 1020 | struct net *net = sock_net(sk); |
1010 | struct unix_sock *u = unix_sk(sk), *newu, *otheru; | 1021 | struct unix_sock *u = unix_sk(sk), *newu, *otheru; |
@@ -1126,8 +1137,7 @@ restart: | |||
1126 | newsk->sk_state = TCP_ESTABLISHED; | 1137 | newsk->sk_state = TCP_ESTABLISHED; |
1127 | newsk->sk_type = sk->sk_type; | 1138 | newsk->sk_type = sk->sk_type; |
1128 | newsk->sk_peercred.pid = task_tgid_vnr(current); | 1139 | newsk->sk_peercred.pid = task_tgid_vnr(current); |
1129 | newsk->sk_peercred.uid = current->euid; | 1140 | current_euid_egid(&newsk->sk_peercred.uid, &newsk->sk_peercred.gid); |
1130 | newsk->sk_peercred.gid = current->egid; | ||
1131 | newu = unix_sk(newsk); | 1141 | newu = unix_sk(newsk); |
1132 | newsk->sk_sleep = &newu->peer_wait; | 1142 | newsk->sk_sleep = &newu->peer_wait; |
1133 | otheru = unix_sk(other); | 1143 | otheru = unix_sk(other); |
@@ -1179,16 +1189,17 @@ out: | |||
1179 | 1189 | ||
1180 | static int unix_socketpair(struct socket *socka, struct socket *sockb) | 1190 | static int unix_socketpair(struct socket *socka, struct socket *sockb) |
1181 | { | 1191 | { |
1182 | struct sock *ska=socka->sk, *skb = sockb->sk; | 1192 | struct sock *ska = socka->sk, *skb = sockb->sk; |
1183 | 1193 | ||
1184 | /* Join our sockets back to back */ | 1194 | /* Join our sockets back to back */ |
1185 | sock_hold(ska); | 1195 | sock_hold(ska); |
1186 | sock_hold(skb); | 1196 | sock_hold(skb); |
1187 | unix_peer(ska)=skb; | 1197 | unix_peer(ska) = skb; |
1188 | unix_peer(skb)=ska; | 1198 | unix_peer(skb) = ska; |
1189 | ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current); | 1199 | ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current); |
1190 | ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid; | 1200 | current_euid_egid(&skb->sk_peercred.uid, &skb->sk_peercred.gid); |
1191 | ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid; | 1201 | ska->sk_peercred.uid = skb->sk_peercred.uid; |
1202 | ska->sk_peercred.gid = skb->sk_peercred.gid; | ||
1192 | 1203 | ||
1193 | if (ska->sk_type != SOCK_DGRAM) { | 1204 | if (ska->sk_type != SOCK_DGRAM) { |
1194 | ska->sk_state = TCP_ESTABLISHED; | 1205 | ska->sk_state = TCP_ESTABLISHED; |
@@ -1207,7 +1218,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags) | |||
1207 | int err; | 1218 | int err; |
1208 | 1219 | ||
1209 | err = -EOPNOTSUPP; | 1220 | err = -EOPNOTSUPP; |
1210 | if (sock->type!=SOCK_STREAM && sock->type!=SOCK_SEQPACKET) | 1221 | if (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET) |
1211 | goto out; | 1222 | goto out; |
1212 | 1223 | ||
1213 | err = -EINVAL; | 1224 | err = -EINVAL; |
@@ -1246,7 +1257,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_ | |||
1246 | { | 1257 | { |
1247 | struct sock *sk = sock->sk; | 1258 | struct sock *sk = sock->sk; |
1248 | struct unix_sock *u; | 1259 | struct unix_sock *u; |
1249 | struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; | 1260 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; |
1250 | int err = 0; | 1261 | int err = 0; |
1251 | 1262 | ||
1252 | if (peer) { | 1263 | if (peer) { |
@@ -1286,7 +1297,7 @@ static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb) | |||
1286 | skb->destructor = sock_wfree; | 1297 | skb->destructor = sock_wfree; |
1287 | UNIXCB(skb).fp = NULL; | 1298 | UNIXCB(skb).fp = NULL; |
1288 | 1299 | ||
1289 | for (i=scm->fp->count-1; i>=0; i--) | 1300 | for (i = scm->fp->count-1; i >= 0; i--) |
1290 | unix_notinflight(scm->fp->fp[i]); | 1301 | unix_notinflight(scm->fp->fp[i]); |
1291 | } | 1302 | } |
1292 | 1303 | ||
@@ -1315,7 +1326,7 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb) | |||
1315 | if (!UNIXCB(skb).fp) | 1326 | if (!UNIXCB(skb).fp) |
1316 | return -ENOMEM; | 1327 | return -ENOMEM; |
1317 | 1328 | ||
1318 | for (i=scm->fp->count-1; i>=0; i--) | 1329 | for (i = scm->fp->count-1; i >= 0; i--) |
1319 | unix_inflight(scm->fp->fp[i]); | 1330 | unix_inflight(scm->fp->fp[i]); |
1320 | skb->destructor = unix_destruct_fds; | 1331 | skb->destructor = unix_destruct_fds; |
1321 | return 0; | 1332 | return 0; |
@@ -1332,7 +1343,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1332 | struct sock *sk = sock->sk; | 1343 | struct sock *sk = sock->sk; |
1333 | struct net *net = sock_net(sk); | 1344 | struct net *net = sock_net(sk); |
1334 | struct unix_sock *u = unix_sk(sk); | 1345 | struct unix_sock *u = unix_sk(sk); |
1335 | struct sockaddr_un *sunaddr=msg->msg_name; | 1346 | struct sockaddr_un *sunaddr = msg->msg_name; |
1336 | struct sock *other = NULL; | 1347 | struct sock *other = NULL; |
1337 | int namelen = 0; /* fake GCC */ | 1348 | int namelen = 0; /* fake GCC */ |
1338 | int err; | 1349 | int err; |
@@ -1374,7 +1385,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1374 | goto out; | 1385 | goto out; |
1375 | 1386 | ||
1376 | skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err); | 1387 | skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err); |
1377 | if (skb==NULL) | 1388 | if (skb == NULL) |
1378 | goto out; | 1389 | goto out; |
1379 | 1390 | ||
1380 | memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); | 1391 | memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); |
@@ -1386,7 +1397,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1386 | unix_get_secdata(siocb->scm, skb); | 1397 | unix_get_secdata(siocb->scm, skb); |
1387 | 1398 | ||
1388 | skb_reset_transport_header(skb); | 1399 | skb_reset_transport_header(skb); |
1389 | err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); | 1400 | err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); |
1390 | if (err) | 1401 | if (err) |
1391 | goto out_free; | 1402 | goto out_free; |
1392 | 1403 | ||
@@ -1400,7 +1411,7 @@ restart: | |||
1400 | 1411 | ||
1401 | other = unix_find_other(net, sunaddr, namelen, sk->sk_type, | 1412 | other = unix_find_other(net, sunaddr, namelen, sk->sk_type, |
1402 | hash, &err); | 1413 | hash, &err); |
1403 | if (other==NULL) | 1414 | if (other == NULL) |
1404 | goto out_free; | 1415 | goto out_free; |
1405 | } | 1416 | } |
1406 | 1417 | ||
@@ -1420,7 +1431,7 @@ restart: | |||
1420 | err = 0; | 1431 | err = 0; |
1421 | unix_state_lock(sk); | 1432 | unix_state_lock(sk); |
1422 | if (unix_peer(sk) == other) { | 1433 | if (unix_peer(sk) == other) { |
1423 | unix_peer(sk)=NULL; | 1434 | unix_peer(sk) = NULL; |
1424 | unix_state_unlock(sk); | 1435 | unix_state_unlock(sk); |
1425 | 1436 | ||
1426 | unix_dgram_disconnected(sk, other); | 1437 | unix_dgram_disconnected(sk, other); |
@@ -1486,10 +1497,10 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1486 | struct sock_iocb *siocb = kiocb_to_siocb(kiocb); | 1497 | struct sock_iocb *siocb = kiocb_to_siocb(kiocb); |
1487 | struct sock *sk = sock->sk; | 1498 | struct sock *sk = sock->sk; |
1488 | struct sock *other = NULL; | 1499 | struct sock *other = NULL; |
1489 | struct sockaddr_un *sunaddr=msg->msg_name; | 1500 | struct sockaddr_un *sunaddr = msg->msg_name; |
1490 | int err,size; | 1501 | int err, size; |
1491 | struct sk_buff *skb; | 1502 | struct sk_buff *skb; |
1492 | int sent=0; | 1503 | int sent = 0; |
1493 | struct scm_cookie tmp_scm; | 1504 | struct scm_cookie tmp_scm; |
1494 | 1505 | ||
1495 | if (NULL == siocb->scm) | 1506 | if (NULL == siocb->scm) |
@@ -1517,8 +1528,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1517 | if (sk->sk_shutdown & SEND_SHUTDOWN) | 1528 | if (sk->sk_shutdown & SEND_SHUTDOWN) |
1518 | goto pipe_err; | 1529 | goto pipe_err; |
1519 | 1530 | ||
1520 | while(sent < len) | 1531 | while (sent < len) { |
1521 | { | ||
1522 | /* | 1532 | /* |
1523 | * Optimisation for the fact that under 0.01% of X | 1533 | * Optimisation for the fact that under 0.01% of X |
1524 | * messages typically need breaking up. | 1534 | * messages typically need breaking up. |
@@ -1537,9 +1547,10 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1537 | * Grab a buffer | 1547 | * Grab a buffer |
1538 | */ | 1548 | */ |
1539 | 1549 | ||
1540 | skb=sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err); | 1550 | skb = sock_alloc_send_skb(sk, size, msg->msg_flags&MSG_DONTWAIT, |
1551 | &err); | ||
1541 | 1552 | ||
1542 | if (skb==NULL) | 1553 | if (skb == NULL) |
1543 | goto out_err; | 1554 | goto out_err; |
1544 | 1555 | ||
1545 | /* | 1556 | /* |
@@ -1560,7 +1571,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1560 | } | 1571 | } |
1561 | } | 1572 | } |
1562 | 1573 | ||
1563 | if ((err = memcpy_fromiovec(skb_put(skb,size), msg->msg_iov, size)) != 0) { | 1574 | err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); |
1575 | if (err) { | ||
1564 | kfree_skb(skb); | 1576 | kfree_skb(skb); |
1565 | goto out_err; | 1577 | goto out_err; |
1566 | } | 1578 | } |
@@ -1574,7 +1586,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1574 | skb_queue_tail(&other->sk_receive_queue, skb); | 1586 | skb_queue_tail(&other->sk_receive_queue, skb); |
1575 | unix_state_unlock(other); | 1587 | unix_state_unlock(other); |
1576 | other->sk_data_ready(other, size); | 1588 | other->sk_data_ready(other, size); |
1577 | sent+=size; | 1589 | sent += size; |
1578 | } | 1590 | } |
1579 | 1591 | ||
1580 | scm_destroy(siocb->scm); | 1592 | scm_destroy(siocb->scm); |
@@ -1586,8 +1598,8 @@ pipe_err_free: | |||
1586 | unix_state_unlock(other); | 1598 | unix_state_unlock(other); |
1587 | kfree_skb(skb); | 1599 | kfree_skb(skb); |
1588 | pipe_err: | 1600 | pipe_err: |
1589 | if (sent==0 && !(msg->msg_flags&MSG_NOSIGNAL)) | 1601 | if (sent == 0 && !(msg->msg_flags&MSG_NOSIGNAL)) |
1590 | send_sig(SIGPIPE,current,0); | 1602 | send_sig(SIGPIPE, current, 0); |
1591 | err = -EPIPE; | 1603 | err = -EPIPE; |
1592 | out_err: | 1604 | out_err: |
1593 | scm_destroy(siocb->scm); | 1605 | scm_destroy(siocb->scm); |
@@ -1677,13 +1689,10 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1677 | siocb->scm->creds = *UNIXCREDS(skb); | 1689 | siocb->scm->creds = *UNIXCREDS(skb); |
1678 | unix_set_secdata(siocb->scm, skb); | 1690 | unix_set_secdata(siocb->scm, skb); |
1679 | 1691 | ||
1680 | if (!(flags & MSG_PEEK)) | 1692 | if (!(flags & MSG_PEEK)) { |
1681 | { | ||
1682 | if (UNIXCB(skb).fp) | 1693 | if (UNIXCB(skb).fp) |
1683 | unix_detach_fds(siocb->scm, skb); | 1694 | unix_detach_fds(siocb->scm, skb); |
1684 | } | 1695 | } else { |
1685 | else | ||
1686 | { | ||
1687 | /* It is questionable: on PEEK we could: | 1696 | /* It is questionable: on PEEK we could: |
1688 | - do not return fds - good, but too simple 8) | 1697 | - do not return fds - good, but too simple 8) |
1689 | - return fds, and do not return them on read (old strategy, | 1698 | - return fds, and do not return them on read (old strategy, |
@@ -1704,7 +1713,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1704 | scm_recv(sock, msg, siocb->scm, flags); | 1713 | scm_recv(sock, msg, siocb->scm, flags); |
1705 | 1714 | ||
1706 | out_free: | 1715 | out_free: |
1707 | skb_free_datagram(sk,skb); | 1716 | skb_free_datagram(sk, skb); |
1708 | out_unlock: | 1717 | out_unlock: |
1709 | mutex_unlock(&u->readlock); | 1718 | mutex_unlock(&u->readlock); |
1710 | out: | 1719 | out: |
@@ -1715,7 +1724,7 @@ out: | |||
1715 | * Sleep until data has arrive. But check for races.. | 1724 | * Sleep until data has arrive. But check for races.. |
1716 | */ | 1725 | */ |
1717 | 1726 | ||
1718 | static long unix_stream_data_wait(struct sock * sk, long timeo) | 1727 | static long unix_stream_data_wait(struct sock *sk, long timeo) |
1719 | { | 1728 | { |
1720 | DEFINE_WAIT(wait); | 1729 | DEFINE_WAIT(wait); |
1721 | 1730 | ||
@@ -1753,7 +1762,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1753 | struct scm_cookie tmp_scm; | 1762 | struct scm_cookie tmp_scm; |
1754 | struct sock *sk = sock->sk; | 1763 | struct sock *sk = sock->sk; |
1755 | struct unix_sock *u = unix_sk(sk); | 1764 | struct unix_sock *u = unix_sk(sk); |
1756 | struct sockaddr_un *sunaddr=msg->msg_name; | 1765 | struct sockaddr_un *sunaddr = msg->msg_name; |
1757 | int copied = 0; | 1766 | int copied = 0; |
1758 | int check_creds = 0; | 1767 | int check_creds = 0; |
1759 | int target; | 1768 | int target; |
@@ -1784,15 +1793,13 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1784 | 1793 | ||
1785 | mutex_lock(&u->readlock); | 1794 | mutex_lock(&u->readlock); |
1786 | 1795 | ||
1787 | do | 1796 | do { |
1788 | { | ||
1789 | int chunk; | 1797 | int chunk; |
1790 | struct sk_buff *skb; | 1798 | struct sk_buff *skb; |
1791 | 1799 | ||
1792 | unix_state_lock(sk); | 1800 | unix_state_lock(sk); |
1793 | skb = skb_dequeue(&sk->sk_receive_queue); | 1801 | skb = skb_dequeue(&sk->sk_receive_queue); |
1794 | if (skb==NULL) | 1802 | if (skb == NULL) { |
1795 | { | ||
1796 | if (copied >= target) | 1803 | if (copied >= target) |
1797 | goto unlock; | 1804 | goto unlock; |
1798 | 1805 | ||
@@ -1800,7 +1807,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1800 | * POSIX 1003.1g mandates this order. | 1807 | * POSIX 1003.1g mandates this order. |
1801 | */ | 1808 | */ |
1802 | 1809 | ||
1803 | if ((err = sock_error(sk)) != 0) | 1810 | err = sock_error(sk); |
1811 | if (err) | ||
1804 | goto unlock; | 1812 | goto unlock; |
1805 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 1813 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
1806 | goto unlock; | 1814 | goto unlock; |
@@ -1827,7 +1835,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1827 | 1835 | ||
1828 | if (check_creds) { | 1836 | if (check_creds) { |
1829 | /* Never glue messages from different writers */ | 1837 | /* Never glue messages from different writers */ |
1830 | if (memcmp(UNIXCREDS(skb), &siocb->scm->creds, sizeof(siocb->scm->creds)) != 0) { | 1838 | if (memcmp(UNIXCREDS(skb), &siocb->scm->creds, |
1839 | sizeof(siocb->scm->creds)) != 0) { | ||
1831 | skb_queue_head(&sk->sk_receive_queue, skb); | 1840 | skb_queue_head(&sk->sk_receive_queue, skb); |
1832 | break; | 1841 | break; |
1833 | } | 1842 | } |
@@ -1838,8 +1847,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1838 | } | 1847 | } |
1839 | 1848 | ||
1840 | /* Copy address just once */ | 1849 | /* Copy address just once */ |
1841 | if (sunaddr) | 1850 | if (sunaddr) { |
1842 | { | ||
1843 | unix_copy_addr(msg, skb->sk); | 1851 | unix_copy_addr(msg, skb->sk); |
1844 | sunaddr = NULL; | 1852 | sunaddr = NULL; |
1845 | } | 1853 | } |
@@ -1855,16 +1863,14 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1855 | size -= chunk; | 1863 | size -= chunk; |
1856 | 1864 | ||
1857 | /* Mark read part of skb as used */ | 1865 | /* Mark read part of skb as used */ |
1858 | if (!(flags & MSG_PEEK)) | 1866 | if (!(flags & MSG_PEEK)) { |
1859 | { | ||
1860 | skb_pull(skb, chunk); | 1867 | skb_pull(skb, chunk); |
1861 | 1868 | ||
1862 | if (UNIXCB(skb).fp) | 1869 | if (UNIXCB(skb).fp) |
1863 | unix_detach_fds(siocb->scm, skb); | 1870 | unix_detach_fds(siocb->scm, skb); |
1864 | 1871 | ||
1865 | /* put the skb back if we didn't use it up.. */ | 1872 | /* put the skb back if we didn't use it up.. */ |
1866 | if (skb->len) | 1873 | if (skb->len) { |
1867 | { | ||
1868 | skb_queue_head(&sk->sk_receive_queue, skb); | 1874 | skb_queue_head(&sk->sk_receive_queue, skb); |
1869 | break; | 1875 | break; |
1870 | } | 1876 | } |
@@ -1873,9 +1879,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1873 | 1879 | ||
1874 | if (siocb->scm->fp) | 1880 | if (siocb->scm->fp) |
1875 | break; | 1881 | break; |
1876 | } | 1882 | } else { |
1877 | else | ||
1878 | { | ||
1879 | /* It is questionable, see note in unix_dgram_recvmsg. | 1883 | /* It is questionable, see note in unix_dgram_recvmsg. |
1880 | */ | 1884 | */ |
1881 | if (UNIXCB(skb).fp) | 1885 | if (UNIXCB(skb).fp) |
@@ -1903,7 +1907,7 @@ static int unix_shutdown(struct socket *sock, int mode) | |||
1903 | if (mode) { | 1907 | if (mode) { |
1904 | unix_state_lock(sk); | 1908 | unix_state_lock(sk); |
1905 | sk->sk_shutdown |= mode; | 1909 | sk->sk_shutdown |= mode; |
1906 | other=unix_peer(sk); | 1910 | other = unix_peer(sk); |
1907 | if (other) | 1911 | if (other) |
1908 | sock_hold(other); | 1912 | sock_hold(other); |
1909 | unix_state_unlock(sk); | 1913 | unix_state_unlock(sk); |
@@ -1938,16 +1942,15 @@ static int unix_shutdown(struct socket *sock, int mode) | |||
1938 | static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 1942 | static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
1939 | { | 1943 | { |
1940 | struct sock *sk = sock->sk; | 1944 | struct sock *sk = sock->sk; |
1941 | long amount=0; | 1945 | long amount = 0; |
1942 | int err; | 1946 | int err; |
1943 | 1947 | ||
1944 | switch(cmd) | 1948 | switch (cmd) { |
1945 | { | 1949 | case SIOCOUTQ: |
1946 | case SIOCOUTQ: | 1950 | amount = atomic_read(&sk->sk_wmem_alloc); |
1947 | amount = atomic_read(&sk->sk_wmem_alloc); | 1951 | err = put_user(amount, (int __user *)arg); |
1948 | err = put_user(amount, (int __user *)arg); | 1952 | break; |
1949 | break; | 1953 | case SIOCINQ: |
1950 | case SIOCINQ: | ||
1951 | { | 1954 | { |
1952 | struct sk_buff *skb; | 1955 | struct sk_buff *skb; |
1953 | 1956 | ||
@@ -1964,21 +1967,21 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1964 | } else { | 1967 | } else { |
1965 | skb = skb_peek(&sk->sk_receive_queue); | 1968 | skb = skb_peek(&sk->sk_receive_queue); |
1966 | if (skb) | 1969 | if (skb) |
1967 | amount=skb->len; | 1970 | amount = skb->len; |
1968 | } | 1971 | } |
1969 | spin_unlock(&sk->sk_receive_queue.lock); | 1972 | spin_unlock(&sk->sk_receive_queue.lock); |
1970 | err = put_user(amount, (int __user *)arg); | 1973 | err = put_user(amount, (int __user *)arg); |
1971 | break; | 1974 | break; |
1972 | } | 1975 | } |
1973 | 1976 | ||
1974 | default: | 1977 | default: |
1975 | err = -ENOIOCTLCMD; | 1978 | err = -ENOIOCTLCMD; |
1976 | break; | 1979 | break; |
1977 | } | 1980 | } |
1978 | return err; | 1981 | return err; |
1979 | } | 1982 | } |
1980 | 1983 | ||
1981 | static unsigned int unix_poll(struct file * file, struct socket *sock, poll_table *wait) | 1984 | static unsigned int unix_poll(struct file *file, struct socket *sock, poll_table *wait) |
1982 | { | 1985 | { |
1983 | struct sock *sk = sock->sk; | 1986 | struct sock *sk = sock->sk; |
1984 | unsigned int mask; | 1987 | unsigned int mask; |
@@ -2000,7 +2003,8 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl | |||
2000 | mask |= POLLIN | POLLRDNORM; | 2003 | mask |= POLLIN | POLLRDNORM; |
2001 | 2004 | ||
2002 | /* Connection-based need to check for termination and startup */ | 2005 | /* Connection-based need to check for termination and startup */ |
2003 | if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && sk->sk_state == TCP_CLOSE) | 2006 | if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && |
2007 | sk->sk_state == TCP_CLOSE) | ||
2004 | mask |= POLLHUP; | 2008 | mask |= POLLHUP; |
2005 | 2009 | ||
2006 | /* | 2010 | /* |
@@ -2096,6 +2100,7 @@ struct unix_iter_state { | |||
2096 | struct seq_net_private p; | 2100 | struct seq_net_private p; |
2097 | int i; | 2101 | int i; |
2098 | }; | 2102 | }; |
2103 | |||
2099 | static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos) | 2104 | static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos) |
2100 | { | 2105 | { |
2101 | struct unix_iter_state *iter = seq->private; | 2106 | struct unix_iter_state *iter = seq->private; |
@@ -2112,7 +2117,6 @@ static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos) | |||
2112 | return NULL; | 2117 | return NULL; |
2113 | } | 2118 | } |
2114 | 2119 | ||
2115 | |||
2116 | static void *unix_seq_start(struct seq_file *seq, loff_t *pos) | 2120 | static void *unix_seq_start(struct seq_file *seq, loff_t *pos) |
2117 | __acquires(unix_table_lock) | 2121 | __acquires(unix_table_lock) |
2118 | { | 2122 | { |
@@ -2192,7 +2196,6 @@ static const struct seq_operations unix_seq_ops = { | |||
2192 | .show = unix_seq_show, | 2196 | .show = unix_seq_show, |
2193 | }; | 2197 | }; |
2194 | 2198 | ||
2195 | |||
2196 | static int unix_seq_open(struct inode *inode, struct file *file) | 2199 | static int unix_seq_open(struct inode *inode, struct file *file) |
2197 | { | 2200 | { |
2198 | return seq_open_net(inode, file, &unix_seq_ops, | 2201 | return seq_open_net(inode, file, &unix_seq_ops, |
diff --git a/net/unix/garbage.c b/net/unix/garbage.c index abb3ab34cb1e..19c17e4a0c8b 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c | |||
@@ -106,8 +106,8 @@ static struct sock *unix_get_socket(struct file *filp) | |||
106 | * Socket ? | 106 | * Socket ? |
107 | */ | 107 | */ |
108 | if (S_ISSOCK(inode->i_mode)) { | 108 | if (S_ISSOCK(inode->i_mode)) { |
109 | struct socket * sock = SOCKET_I(inode); | 109 | struct socket *sock = SOCKET_I(inode); |
110 | struct sock * s = sock->sk; | 110 | struct sock *s = sock->sk; |
111 | 111 | ||
112 | /* | 112 | /* |
113 | * PF_UNIX ? | 113 | * PF_UNIX ? |
@@ -126,7 +126,7 @@ static struct sock *unix_get_socket(struct file *filp) | |||
126 | void unix_inflight(struct file *fp) | 126 | void unix_inflight(struct file *fp) |
127 | { | 127 | { |
128 | struct sock *s = unix_get_socket(fp); | 128 | struct sock *s = unix_get_socket(fp); |
129 | if(s) { | 129 | if (s) { |
130 | struct unix_sock *u = unix_sk(s); | 130 | struct unix_sock *u = unix_sk(s); |
131 | spin_lock(&unix_gc_lock); | 131 | spin_lock(&unix_gc_lock); |
132 | if (atomic_long_inc_return(&u->inflight) == 1) { | 132 | if (atomic_long_inc_return(&u->inflight) == 1) { |
@@ -143,7 +143,7 @@ void unix_inflight(struct file *fp) | |||
143 | void unix_notinflight(struct file *fp) | 143 | void unix_notinflight(struct file *fp) |
144 | { | 144 | { |
145 | struct sock *s = unix_get_socket(fp); | 145 | struct sock *s = unix_get_socket(fp); |
146 | if(s) { | 146 | if (s) { |
147 | struct unix_sock *u = unix_sk(s); | 147 | struct unix_sock *u = unix_sk(s); |
148 | spin_lock(&unix_gc_lock); | 148 | spin_lock(&unix_gc_lock); |
149 | BUG_ON(list_empty(&u->link)); | 149 | BUG_ON(list_empty(&u->link)); |
@@ -156,7 +156,7 @@ void unix_notinflight(struct file *fp) | |||
156 | 156 | ||
157 | static inline struct sk_buff *sock_queue_head(struct sock *sk) | 157 | static inline struct sk_buff *sock_queue_head(struct sock *sk) |
158 | { | 158 | { |
159 | return (struct sk_buff *) &sk->sk_receive_queue; | 159 | return (struct sk_buff *)&sk->sk_receive_queue; |
160 | } | 160 | } |
161 | 161 | ||
162 | #define receive_queue_for_each_skb(sk, next, skb) \ | 162 | #define receive_queue_for_each_skb(sk, next, skb) \ |
@@ -370,7 +370,7 @@ void unix_gc(void) | |||
370 | */ | 370 | */ |
371 | skb_queue_head_init(&hitlist); | 371 | skb_queue_head_init(&hitlist); |
372 | list_for_each_entry(u, &gc_candidates, link) | 372 | list_for_each_entry(u, &gc_candidates, link) |
373 | scan_children(&u->sk, inc_inflight, &hitlist); | 373 | scan_children(&u->sk, inc_inflight, &hitlist); |
374 | 374 | ||
375 | spin_unlock(&unix_gc_lock); | 375 | spin_unlock(&unix_gc_lock); |
376 | 376 | ||
diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 77513d7e35f2..83c093077ebc 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c | |||
@@ -21,7 +21,7 @@ static ctl_table unix_table[] = { | |||
21 | .data = &init_net.unx.sysctl_max_dgram_qlen, | 21 | .data = &init_net.unx.sysctl_max_dgram_qlen, |
22 | .maxlen = sizeof(int), | 22 | .maxlen = sizeof(int), |
23 | .mode = 0644, | 23 | .mode = 0644, |
24 | .proc_handler = &proc_dointvec | 24 | .proc_handler = proc_dointvec |
25 | }, | 25 | }, |
26 | { .ctl_name = 0 } | 26 | { .ctl_name = 0 } |
27 | }; | 27 | }; |
@@ -61,4 +61,3 @@ void unix_sysctl_unregister(struct net *net) | |||
61 | unregister_sysctl_table(net->unx.ctl); | 61 | unregister_sysctl_table(net->unx.ctl); |
62 | kfree(table); | 62 | kfree(table); |
63 | } | 63 | } |
64 | |||