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.c1
3 files changed, 42 insertions, 44 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index dc504d308ec0..0b80634b2b72 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) {
@@ -1323,7 +1323,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1323 struct sock *sk = sock->sk; 1323 struct sock *sk = sock->sk;
1324 struct net *net = sock_net(sk); 1324 struct net *net = sock_net(sk);
1325 struct unix_sock *u = unix_sk(sk); 1325 struct unix_sock *u = unix_sk(sk);
1326 struct sockaddr_un *sunaddr=msg->msg_name; 1326 struct sockaddr_un *sunaddr = msg->msg_name;
1327 struct sock *other = NULL; 1327 struct sock *other = NULL;
1328 int namelen = 0; /* fake GCC */ 1328 int namelen = 0; /* fake GCC */
1329 int err; 1329 int err;
@@ -1364,7 +1364,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1364 goto out; 1364 goto out;
1365 1365
1366 skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err); 1366 skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err);
1367 if (skb==NULL) 1367 if (skb == NULL)
1368 goto out; 1368 goto out;
1369 1369
1370 memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); 1370 memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred));
@@ -1387,7 +1387,7 @@ restart:
1387 1387
1388 other = unix_find_other(net, sunaddr, namelen, sk->sk_type, 1388 other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
1389 hash, &err); 1389 hash, &err);
1390 if (other==NULL) 1390 if (other == NULL)
1391 goto out_free; 1391 goto out_free;
1392 } 1392 }
1393 1393
@@ -1407,7 +1407,7 @@ restart:
1407 err = 0; 1407 err = 0;
1408 unix_state_lock(sk); 1408 unix_state_lock(sk);
1409 if (unix_peer(sk) == other) { 1409 if (unix_peer(sk) == other) {
1410 unix_peer(sk)=NULL; 1410 unix_peer(sk) = NULL;
1411 unix_state_unlock(sk); 1411 unix_state_unlock(sk);
1412 1412
1413 unix_dgram_disconnected(sk, other); 1413 unix_dgram_disconnected(sk, other);
@@ -1473,10 +1473,10 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1473 struct sock_iocb *siocb = kiocb_to_siocb(kiocb); 1473 struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
1474 struct sock *sk = sock->sk; 1474 struct sock *sk = sock->sk;
1475 struct sock *other = NULL; 1475 struct sock *other = NULL;
1476 struct sockaddr_un *sunaddr=msg->msg_name; 1476 struct sockaddr_un *sunaddr = msg->msg_name;
1477 int err,size; 1477 int err,size;
1478 struct sk_buff *skb; 1478 struct sk_buff *skb;
1479 int sent=0; 1479 int sent = 0;
1480 struct scm_cookie tmp_scm; 1480 struct scm_cookie tmp_scm;
1481 1481
1482 if (NULL == siocb->scm) 1482 if (NULL == siocb->scm)
@@ -1523,9 +1523,9 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1523 * Grab a buffer 1523 * Grab a buffer
1524 */ 1524 */
1525 1525
1526 skb=sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err); 1526 skb = sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err);
1527 1527
1528 if (skb==NULL) 1528 if (skb == NULL)
1529 goto out_err; 1529 goto out_err;
1530 1530
1531 /* 1531 /*
@@ -1555,7 +1555,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1555 skb_queue_tail(&other->sk_receive_queue, skb); 1555 skb_queue_tail(&other->sk_receive_queue, skb);
1556 unix_state_unlock(other); 1556 unix_state_unlock(other);
1557 other->sk_data_ready(other, size); 1557 other->sk_data_ready(other, size);
1558 sent+=size; 1558 sent += size;
1559 } 1559 }
1560 1560
1561 scm_destroy(siocb->scm); 1561 scm_destroy(siocb->scm);
@@ -1734,7 +1734,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1734 struct scm_cookie tmp_scm; 1734 struct scm_cookie tmp_scm;
1735 struct sock *sk = sock->sk; 1735 struct sock *sk = sock->sk;
1736 struct unix_sock *u = unix_sk(sk); 1736 struct unix_sock *u = unix_sk(sk);
1737 struct sockaddr_un *sunaddr=msg->msg_name; 1737 struct sockaddr_un *sunaddr = msg->msg_name;
1738 int copied = 0; 1738 int copied = 0;
1739 int check_creds = 0; 1739 int check_creds = 0;
1740 int target; 1740 int target;
@@ -1772,7 +1772,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1772 1772
1773 unix_state_lock(sk); 1773 unix_state_lock(sk);
1774 skb = skb_dequeue(&sk->sk_receive_queue); 1774 skb = skb_dequeue(&sk->sk_receive_queue);
1775 if (skb==NULL) 1775 if (skb == NULL)
1776 { 1776 {
1777 if (copied >= target) 1777 if (copied >= target)
1778 goto unlock; 1778 goto unlock;
@@ -1884,7 +1884,7 @@ static int unix_shutdown(struct socket *sock, int mode)
1884 if (mode) { 1884 if (mode) {
1885 unix_state_lock(sk); 1885 unix_state_lock(sk);
1886 sk->sk_shutdown |= mode; 1886 sk->sk_shutdown |= mode;
1887 other=unix_peer(sk); 1887 other = unix_peer(sk);
1888 if (other) 1888 if (other)
1889 sock_hold(other); 1889 sock_hold(other);
1890 unix_state_unlock(sk); 1890 unix_state_unlock(sk);
@@ -1919,7 +1919,7 @@ static int unix_shutdown(struct socket *sock, int mode)
1919static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 1919static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1920{ 1920{
1921 struct sock *sk = sock->sk; 1921 struct sock *sk = sock->sk;
1922 long amount=0; 1922 long amount = 0;
1923 int err; 1923 int err;
1924 1924
1925 switch(cmd) 1925 switch(cmd)
@@ -1945,7 +1945,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1945 } else { 1945 } else {
1946 skb = skb_peek(&sk->sk_receive_queue); 1946 skb = skb_peek(&sk->sk_receive_queue);
1947 if (skb) 1947 if (skb)
1948 amount=skb->len; 1948 amount = skb->len;
1949 } 1949 }
1950 spin_unlock(&sk->sk_receive_queue.lock); 1950 spin_unlock(&sk->sk_receive_queue.lock);
1951 err = put_user(amount, (int __user *)arg); 1951 err = put_user(amount, (int __user *)arg);
@@ -2077,6 +2077,7 @@ struct unix_iter_state {
2077 struct seq_net_private p; 2077 struct seq_net_private p;
2078 int i; 2078 int i;
2079}; 2079};
2080
2080static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos) 2081static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2081{ 2082{
2082 struct unix_iter_state *iter = seq->private; 2083 struct unix_iter_state *iter = seq->private;
@@ -2093,7 +2094,6 @@ static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2093 return NULL; 2094 return NULL;
2094} 2095}
2095 2096
2096
2097static void *unix_seq_start(struct seq_file *seq, loff_t *pos) 2097static void *unix_seq_start(struct seq_file *seq, loff_t *pos)
2098 __acquires(unix_table_lock) 2098 __acquires(unix_table_lock)
2099{ 2099{
@@ -2173,7 +2173,6 @@ static const struct seq_operations unix_seq_ops = {
2173 .show = unix_seq_show, 2173 .show = unix_seq_show,
2174}; 2174};
2175 2175
2176
2177static int unix_seq_open(struct inode *inode, struct file *file) 2176static int unix_seq_open(struct inode *inode, struct file *file)
2178{ 2177{
2179 return seq_open_net(inode, file, &unix_seq_ops, 2178 return seq_open_net(inode, file, &unix_seq_ops,
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 2a27b84f740b..00734e22ec15 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) \
@@ -339,7 +339,7 @@ void unix_gc(void)
339 */ 339 */
340 skb_queue_head_init(&hitlist); 340 skb_queue_head_init(&hitlist);
341 list_for_each_entry(u, &gc_candidates, link) 341 list_for_each_entry(u, &gc_candidates, link)
342 scan_children(&u->sk, inc_inflight, &hitlist); 342 scan_children(&u->sk, inc_inflight, &hitlist);
343 343
344 spin_unlock(&unix_gc_lock); 344 spin_unlock(&unix_gc_lock);
345 345
diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
index 77513d7e35f2..1f4040cdadad 100644
--- a/net/unix/sysctl_net_unix.c
+++ b/net/unix/sysctl_net_unix.c
@@ -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