diff options
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r-- | net/unix/af_unix.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 51ab497115eb..3d9122e78f41 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -144,7 +144,7 @@ static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb) | |||
144 | /* | 144 | /* |
145 | * SMP locking strategy: | 145 | * SMP locking strategy: |
146 | * hash table is protected with spinlock unix_table_lock | 146 | * hash table is protected with spinlock unix_table_lock |
147 | * each socket state is protected by separate rwlock. | 147 | * each socket state is protected by separate spin lock. |
148 | */ | 148 | */ |
149 | 149 | ||
150 | static inline unsigned unix_hash_fold(__wsum n) | 150 | static inline unsigned unix_hash_fold(__wsum n) |
@@ -621,7 +621,8 @@ out: | |||
621 | return sk; | 621 | return sk; |
622 | } | 622 | } |
623 | 623 | ||
624 | static int unix_create(struct net *net, struct socket *sock, int protocol) | 624 | static int unix_create(struct net *net, struct socket *sock, int protocol, |
625 | int kern) | ||
625 | { | 626 | { |
626 | if (protocol && protocol != PF_UNIX) | 627 | if (protocol && protocol != PF_UNIX) |
627 | return -EPROTONOSUPPORT; | 628 | return -EPROTONOSUPPORT; |
@@ -1032,8 +1033,8 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, | |||
1032 | goto out; | 1033 | goto out; |
1033 | addr_len = err; | 1034 | addr_len = err; |
1034 | 1035 | ||
1035 | if (test_bit(SOCK_PASSCRED, &sock->flags) | 1036 | if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr && |
1036 | && !u->addr && (err = unix_autobind(sock)) != 0) | 1037 | (err = unix_autobind(sock)) != 0) |
1037 | goto out; | 1038 | goto out; |
1038 | 1039 | ||
1039 | timeo = sock_sndtimeo(sk, flags & O_NONBLOCK); | 1040 | timeo = sock_sndtimeo(sk, flags & O_NONBLOCK); |
@@ -1074,6 +1075,8 @@ restart: | |||
1074 | err = -ECONNREFUSED; | 1075 | err = -ECONNREFUSED; |
1075 | if (other->sk_state != TCP_LISTEN) | 1076 | if (other->sk_state != TCP_LISTEN) |
1076 | goto out_unlock; | 1077 | goto out_unlock; |
1078 | if (other->sk_shutdown & RCV_SHUTDOWN) | ||
1079 | goto out_unlock; | ||
1077 | 1080 | ||
1078 | if (unix_recvq_full(other)) { | 1081 | if (unix_recvq_full(other)) { |
1079 | err = -EAGAIN; | 1082 | err = -EAGAIN; |
@@ -1256,7 +1259,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_ | |||
1256 | { | 1259 | { |
1257 | struct sock *sk = sock->sk; | 1260 | struct sock *sk = sock->sk; |
1258 | struct unix_sock *u; | 1261 | struct unix_sock *u; |
1259 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; | 1262 | DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, uaddr); |
1260 | int err = 0; | 1263 | int err = 0; |
1261 | 1264 | ||
1262 | if (peer) { | 1265 | if (peer) { |
@@ -1375,8 +1378,8 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1375 | goto out; | 1378 | goto out; |
1376 | } | 1379 | } |
1377 | 1380 | ||
1378 | if (test_bit(SOCK_PASSCRED, &sock->flags) | 1381 | if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr |
1379 | && !u->addr && (err = unix_autobind(sock)) != 0) | 1382 | && (err = unix_autobind(sock)) != 0) |
1380 | goto out; | 1383 | goto out; |
1381 | 1384 | ||
1382 | err = -EMSGSIZE; | 1385 | err = -EMSGSIZE; |
@@ -2214,14 +2217,14 @@ static const struct file_operations unix_seq_fops = { | |||
2214 | 2217 | ||
2215 | #endif | 2218 | #endif |
2216 | 2219 | ||
2217 | static struct net_proto_family unix_family_ops = { | 2220 | static const struct net_proto_family unix_family_ops = { |
2218 | .family = PF_UNIX, | 2221 | .family = PF_UNIX, |
2219 | .create = unix_create, | 2222 | .create = unix_create, |
2220 | .owner = THIS_MODULE, | 2223 | .owner = THIS_MODULE, |
2221 | }; | 2224 | }; |
2222 | 2225 | ||
2223 | 2226 | ||
2224 | static int unix_net_init(struct net *net) | 2227 | static int __net_init unix_net_init(struct net *net) |
2225 | { | 2228 | { |
2226 | int error = -ENOMEM; | 2229 | int error = -ENOMEM; |
2227 | 2230 | ||
@@ -2240,7 +2243,7 @@ out: | |||
2240 | return error; | 2243 | return error; |
2241 | } | 2244 | } |
2242 | 2245 | ||
2243 | static void unix_net_exit(struct net *net) | 2246 | static void __net_exit unix_net_exit(struct net *net) |
2244 | { | 2247 | { |
2245 | unix_sysctl_unregister(net); | 2248 | unix_sysctl_unregister(net); |
2246 | proc_net_remove(net, "unix"); | 2249 | proc_net_remove(net, "unix"); |