aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix
diff options
context:
space:
mode:
Diffstat (limited to 'net/unix')
-rw-r--r--net/unix/af_unix.c73
-rw-r--r--net/unix/garbage.c12
-rw-r--r--net/unix/sysctl_net_unix.c3
3 files changed, 43 insertions, 45 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index eb90f77bb0e2..4a39771d037e 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -211,7 +211,7 @@ 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 }
@@ -392,9 +392,9 @@ static int unix_release_sock (struct sock *sk, int embrion)
392 392
393 wake_up_interruptible_all(&u->peer_wait); 393 wake_up_interruptible_all(&u->peer_wait);
394 394
395 skpair=unix_peer(sk); 395 skpair = unix_peer(sk);
396 396
397 if (skpair!=NULL) { 397 if (skpair != NULL) {
398 if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { 398 if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) {
399 unix_state_lock(skpair); 399 unix_state_lock(skpair);
400 /* No more writes */ 400 /* No more writes */
@@ -414,7 +414,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
414 /* Try to flush out this socket. Throw out buffers at least */ 414 /* Try to flush out this socket. Throw out buffers at least */
415 415
416 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 416 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
417 if (state==TCP_LISTEN) 417 if (state == TCP_LISTEN)
418 unix_release_sock(skb->sk, 1); 418 unix_release_sock(skb->sk, 1);
419 /* passed fds are erased in the kfree_skb hook */ 419 /* passed fds are erased in the kfree_skb hook */
420 kfree_skb(skb); 420 kfree_skb(skb);
@@ -630,7 +630,7 @@ static int unix_create(struct net *net, struct socket *sock, int protocol)
630 * nothing uses it. 630 * nothing uses it.
631 */ 631 */
632 case SOCK_RAW: 632 case SOCK_RAW:
633 sock->type=SOCK_DGRAM; 633 sock->type = SOCK_DGRAM;
634 case SOCK_DGRAM: 634 case SOCK_DGRAM:
635 sock->ops = &unix_dgram_ops; 635 sock->ops = &unix_dgram_ops;
636 break; 636 break;
@@ -736,14 +736,14 @@ static struct sock *unix_find_other(struct net *net,
736 736
737 path_put(&path); 737 path_put(&path);
738 738
739 err=-EPROTOTYPE; 739 err = -EPROTOTYPE;
740 if (u->sk_type != type) { 740 if (u->sk_type != type) {
741 sock_put(u); 741 sock_put(u);
742 goto fail; 742 goto fail;
743 } 743 }
744 } else { 744 } else {
745 err = -ECONNREFUSED; 745 err = -ECONNREFUSED;
746 u=unix_find_socket_byname(net, sunname, len, type, hash); 746 u = unix_find_socket_byname(net, sunname, len, type, hash);
747 if (u) { 747 if (u) {
748 struct dentry *dentry; 748 struct dentry *dentry;
749 dentry = unix_sk(u)->dentry; 749 dentry = unix_sk(u)->dentry;
@@ -757,7 +757,7 @@ static struct sock *unix_find_other(struct net *net,
757put_fail: 757put_fail:
758 path_put(&path); 758 path_put(&path);
759fail: 759fail:
760 *error=err; 760 *error = err;
761 return NULL; 761 return NULL;
762} 762}
763 763
@@ -767,7 +767,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
767 struct sock *sk = sock->sk; 767 struct sock *sk = sock->sk;
768 struct net *net = sock_net(sk); 768 struct net *net = sock_net(sk);
769 struct unix_sock *u = unix_sk(sk); 769 struct unix_sock *u = unix_sk(sk);
770 struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; 770 struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
771 struct dentry * dentry = NULL; 771 struct dentry * dentry = NULL;
772 struct nameidata nd; 772 struct nameidata nd;
773 int err; 773 int err;
@@ -779,7 +779,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
779 if (sunaddr->sun_family != AF_UNIX) 779 if (sunaddr->sun_family != AF_UNIX)
780 goto out; 780 goto out;
781 781
782 if (addr_len==sizeof(short)) { 782 if (addr_len == sizeof(short)) {
783 err = unix_autobind(sock); 783 err = unix_autobind(sock);
784 goto out; 784 goto out;
785 } 785 }
@@ -875,8 +875,8 @@ out_mknod_unlock:
875 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 875 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
876 path_put(&nd.path); 876 path_put(&nd.path);
877out_mknod_parent: 877out_mknod_parent:
878 if (err==-EEXIST) 878 if (err == -EEXIST)
879 err=-EADDRINUSE; 879 err = -EADDRINUSE;
880 unix_release_addr(addr); 880 unix_release_addr(addr);
881 goto out_up; 881 goto out_up;
882} 882}
@@ -911,7 +911,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
911{ 911{
912 struct sock *sk = sock->sk; 912 struct sock *sk = sock->sk;
913 struct net *net = sock_net(sk); 913 struct net *net = sock_net(sk);
914 struct sockaddr_un *sunaddr=(struct sockaddr_un*)addr; 914 struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;
915 struct sock *other; 915 struct sock *other;
916 unsigned hash; 916 unsigned hash;
917 int err; 917 int err;
@@ -927,7 +927,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
927 goto out; 927 goto out;
928 928
929restart: 929restart:
930 other=unix_find_other(net, sunaddr, alen, sock->type, hash, &err); 930 other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
931 if (!other) 931 if (!other)
932 goto out; 932 goto out;
933 933
@@ -961,14 +961,14 @@ restart:
961 */ 961 */
962 if (unix_peer(sk)) { 962 if (unix_peer(sk)) {
963 struct sock *old_peer = unix_peer(sk); 963 struct sock *old_peer = unix_peer(sk);
964 unix_peer(sk)=other; 964 unix_peer(sk) = other;
965 unix_state_double_unlock(sk, other); 965 unix_state_double_unlock(sk, other);
966 966
967 if (other != old_peer) 967 if (other != old_peer)
968 unix_dgram_disconnected(sk, old_peer); 968 unix_dgram_disconnected(sk, old_peer);
969 sock_put(old_peer); 969 sock_put(old_peer);
970 } else { 970 } else {
971 unix_peer(sk)=other; 971 unix_peer(sk) = other;
972 unix_state_double_unlock(sk, other); 972 unix_state_double_unlock(sk, other);
973 } 973 }
974 return 0; 974 return 0;
@@ -1004,7 +1004,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo)
1004static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, 1004static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
1005 int addr_len, int flags) 1005 int addr_len, int flags)
1006{ 1006{
1007 struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; 1007 struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
1008 struct sock *sk = sock->sk; 1008 struct sock *sk = sock->sk;
1009 struct net *net = sock_net(sk); 1009 struct net *net = sock_net(sk);
1010 struct unix_sock *u = unix_sk(sk), *newu, *otheru; 1010 struct unix_sock *u = unix_sk(sk), *newu, *otheru;
@@ -1179,13 +1179,13 @@ out:
1179 1179
1180static int unix_socketpair(struct socket *socka, struct socket *sockb) 1180static int unix_socketpair(struct socket *socka, struct socket *sockb)
1181{ 1181{
1182 struct sock *ska=socka->sk, *skb = sockb->sk; 1182 struct sock *ska = socka->sk, *skb = sockb->sk;
1183 1183
1184 /* Join our sockets back to back */ 1184 /* Join our sockets back to back */
1185 sock_hold(ska); 1185 sock_hold(ska);
1186 sock_hold(skb); 1186 sock_hold(skb);
1187 unix_peer(ska)=skb; 1187 unix_peer(ska) = skb;
1188 unix_peer(skb)=ska; 1188 unix_peer(skb) = ska;
1189 ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current); 1189 ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current);
1190 ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid; 1190 ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid;
1191 ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid; 1191 ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid;
@@ -1246,7 +1246,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
1246{ 1246{
1247 struct sock *sk = sock->sk; 1247 struct sock *sk = sock->sk;
1248 struct unix_sock *u; 1248 struct unix_sock *u;
1249 struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr; 1249 struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
1250 int err = 0; 1250 int err = 0;
1251 1251
1252 if (peer) { 1252 if (peer) {
@@ -1332,7 +1332,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1332 struct sock *sk = sock->sk; 1332 struct sock *sk = sock->sk;
1333 struct net *net = sock_net(sk); 1333 struct net *net = sock_net(sk);
1334 struct unix_sock *u = unix_sk(sk); 1334 struct unix_sock *u = unix_sk(sk);
1335 struct sockaddr_un *sunaddr=msg->msg_name; 1335 struct sockaddr_un *sunaddr = msg->msg_name;
1336 struct sock *other = NULL; 1336 struct sock *other = NULL;
1337 int namelen = 0; /* fake GCC */ 1337 int namelen = 0; /* fake GCC */
1338 int err; 1338 int err;
@@ -1373,7 +1373,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1373 goto out; 1373 goto out;
1374 1374
1375 skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err); 1375 skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err);
1376 if (skb==NULL) 1376 if (skb == NULL)
1377 goto out; 1377 goto out;
1378 1378
1379 memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); 1379 memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred));
@@ -1399,7 +1399,7 @@ restart:
1399 1399
1400 other = unix_find_other(net, sunaddr, namelen, sk->sk_type, 1400 other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
1401 hash, &err); 1401 hash, &err);
1402 if (other==NULL) 1402 if (other == NULL)
1403 goto out_free; 1403 goto out_free;
1404 } 1404 }
1405 1405
@@ -1419,7 +1419,7 @@ restart:
1419 err = 0; 1419 err = 0;
1420 unix_state_lock(sk); 1420 unix_state_lock(sk);
1421 if (unix_peer(sk) == other) { 1421 if (unix_peer(sk) == other) {
1422 unix_peer(sk)=NULL; 1422 unix_peer(sk) = NULL;
1423 unix_state_unlock(sk); 1423 unix_state_unlock(sk);
1424 1424
1425 unix_dgram_disconnected(sk, other); 1425 unix_dgram_disconnected(sk, other);
@@ -1485,10 +1485,10 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1485 struct sock_iocb *siocb = kiocb_to_siocb(kiocb); 1485 struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
1486 struct sock *sk = sock->sk; 1486 struct sock *sk = sock->sk;
1487 struct sock *other = NULL; 1487 struct sock *other = NULL;
1488 struct sockaddr_un *sunaddr=msg->msg_name; 1488 struct sockaddr_un *sunaddr = msg->msg_name;
1489 int err,size; 1489 int err,size;
1490 struct sk_buff *skb; 1490 struct sk_buff *skb;
1491 int sent=0; 1491 int sent = 0;
1492 struct scm_cookie tmp_scm; 1492 struct scm_cookie tmp_scm;
1493 1493
1494 if (NULL == siocb->scm) 1494 if (NULL == siocb->scm)
@@ -1535,9 +1535,9 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1535 * Grab a buffer 1535 * Grab a buffer
1536 */ 1536 */
1537 1537
1538 skb=sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err); 1538 skb = sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err);
1539 1539
1540 if (skb==NULL) 1540 if (skb == NULL)
1541 goto out_err; 1541 goto out_err;
1542 1542
1543 /* 1543 /*
@@ -1572,7 +1572,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1572 skb_queue_tail(&other->sk_receive_queue, skb); 1572 skb_queue_tail(&other->sk_receive_queue, skb);
1573 unix_state_unlock(other); 1573 unix_state_unlock(other);
1574 other->sk_data_ready(other, size); 1574 other->sk_data_ready(other, size);
1575 sent+=size; 1575 sent += size;
1576 } 1576 }
1577 1577
1578 scm_destroy(siocb->scm); 1578 scm_destroy(siocb->scm);
@@ -1751,7 +1751,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1751 struct scm_cookie tmp_scm; 1751 struct scm_cookie tmp_scm;
1752 struct sock *sk = sock->sk; 1752 struct sock *sk = sock->sk;
1753 struct unix_sock *u = unix_sk(sk); 1753 struct unix_sock *u = unix_sk(sk);
1754 struct sockaddr_un *sunaddr=msg->msg_name; 1754 struct sockaddr_un *sunaddr = msg->msg_name;
1755 int copied = 0; 1755 int copied = 0;
1756 int check_creds = 0; 1756 int check_creds = 0;
1757 int target; 1757 int target;
@@ -1789,7 +1789,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1789 1789
1790 unix_state_lock(sk); 1790 unix_state_lock(sk);
1791 skb = skb_dequeue(&sk->sk_receive_queue); 1791 skb = skb_dequeue(&sk->sk_receive_queue);
1792 if (skb==NULL) 1792 if (skb == NULL)
1793 { 1793 {
1794 if (copied >= target) 1794 if (copied >= target)
1795 goto unlock; 1795 goto unlock;
@@ -1901,7 +1901,7 @@ static int unix_shutdown(struct socket *sock, int mode)
1901 if (mode) { 1901 if (mode) {
1902 unix_state_lock(sk); 1902 unix_state_lock(sk);
1903 sk->sk_shutdown |= mode; 1903 sk->sk_shutdown |= mode;
1904 other=unix_peer(sk); 1904 other = unix_peer(sk);
1905 if (other) 1905 if (other)
1906 sock_hold(other); 1906 sock_hold(other);
1907 unix_state_unlock(sk); 1907 unix_state_unlock(sk);
@@ -1936,7 +1936,7 @@ static int unix_shutdown(struct socket *sock, int mode)
1936static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 1936static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1937{ 1937{
1938 struct sock *sk = sock->sk; 1938 struct sock *sk = sock->sk;
1939 long amount=0; 1939 long amount = 0;
1940 int err; 1940 int err;
1941 1941
1942 switch(cmd) 1942 switch(cmd)
@@ -1962,7 +1962,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1962 } else { 1962 } else {
1963 skb = skb_peek(&sk->sk_receive_queue); 1963 skb = skb_peek(&sk->sk_receive_queue);
1964 if (skb) 1964 if (skb)
1965 amount=skb->len; 1965 amount = skb->len;
1966 } 1966 }
1967 spin_unlock(&sk->sk_receive_queue.lock); 1967 spin_unlock(&sk->sk_receive_queue.lock);
1968 err = put_user(amount, (int __user *)arg); 1968 err = put_user(amount, (int __user *)arg);
@@ -2094,6 +2094,7 @@ struct unix_iter_state {
2094 struct seq_net_private p; 2094 struct seq_net_private p;
2095 int i; 2095 int i;
2096}; 2096};
2097
2097static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos) 2098static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2098{ 2099{
2099 struct unix_iter_state *iter = seq->private; 2100 struct unix_iter_state *iter = seq->private;
@@ -2110,7 +2111,6 @@ static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2110 return NULL; 2111 return NULL;
2111} 2112}
2112 2113
2113
2114static void *unix_seq_start(struct seq_file *seq, loff_t *pos) 2114static void *unix_seq_start(struct seq_file *seq, loff_t *pos)
2115 __acquires(unix_table_lock) 2115 __acquires(unix_table_lock)
2116{ 2116{
@@ -2190,7 +2190,6 @@ static const struct seq_operations unix_seq_ops = {
2190 .show = unix_seq_show, 2190 .show = unix_seq_show,
2191}; 2191};
2192 2192
2193
2194static int unix_seq_open(struct inode *inode, struct file *file) 2193static int unix_seq_open(struct inode *inode, struct file *file)
2195{ 2194{
2196 return seq_open_net(inode, file, &unix_seq_ops, 2195 return seq_open_net(inode, file, &unix_seq_ops,
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 6d4a9a8de5ef..5a0061d6b9bc 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -104,8 +104,8 @@ static struct sock *unix_get_socket(struct file *filp)
104 * Socket ? 104 * Socket ?
105 */ 105 */
106 if (S_ISSOCK(inode->i_mode)) { 106 if (S_ISSOCK(inode->i_mode)) {
107 struct socket * sock = SOCKET_I(inode); 107 struct socket *sock = SOCKET_I(inode);
108 struct sock * s = sock->sk; 108 struct sock *s = sock->sk;
109 109
110 /* 110 /*
111 * PF_UNIX ? 111 * PF_UNIX ?
@@ -124,7 +124,7 @@ static struct sock *unix_get_socket(struct file *filp)
124void unix_inflight(struct file *fp) 124void unix_inflight(struct file *fp)
125{ 125{
126 struct sock *s = unix_get_socket(fp); 126 struct sock *s = unix_get_socket(fp);
127 if(s) { 127 if (s) {
128 struct unix_sock *u = unix_sk(s); 128 struct unix_sock *u = unix_sk(s);
129 spin_lock(&unix_gc_lock); 129 spin_lock(&unix_gc_lock);
130 if (atomic_long_inc_return(&u->inflight) == 1) { 130 if (atomic_long_inc_return(&u->inflight) == 1) {
@@ -141,7 +141,7 @@ void unix_inflight(struct file *fp)
141void unix_notinflight(struct file *fp) 141void unix_notinflight(struct file *fp)
142{ 142{
143 struct sock *s = unix_get_socket(fp); 143 struct sock *s = unix_get_socket(fp);
144 if(s) { 144 if (s) {
145 struct unix_sock *u = unix_sk(s); 145 struct unix_sock *u = unix_sk(s);
146 spin_lock(&unix_gc_lock); 146 spin_lock(&unix_gc_lock);
147 BUG_ON(list_empty(&u->link)); 147 BUG_ON(list_empty(&u->link));
@@ -154,7 +154,7 @@ void unix_notinflight(struct file *fp)
154 154
155static inline struct sk_buff *sock_queue_head(struct sock *sk) 155static inline struct sk_buff *sock_queue_head(struct sock *sk)
156{ 156{
157 return (struct sk_buff *) &sk->sk_receive_queue; 157 return (struct sk_buff *)&sk->sk_receive_queue;
158} 158}
159 159
160#define receive_queue_for_each_skb(sk, next, skb) \ 160#define receive_queue_for_each_skb(sk, next, skb) \
@@ -364,7 +364,7 @@ void unix_gc(void)
364 */ 364 */
365 skb_queue_head_init(&hitlist); 365 skb_queue_head_init(&hitlist);
366 list_for_each_entry(u, &gc_candidates, link) 366 list_for_each_entry(u, &gc_candidates, link)
367 scan_children(&u->sk, inc_inflight, &hitlist); 367 scan_children(&u->sk, inc_inflight, &hitlist);
368 368
369 spin_unlock(&unix_gc_lock); 369 spin_unlock(&unix_gc_lock);
370 370
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