aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
authorJames Morris <james.l.morris@oracle.com>2017-07-24 20:44:18 -0400
committerJames Morris <james.l.morris@oracle.com>2017-07-24 20:44:18 -0400
commit53a2ebaaabc1eb8458796fec3bc1e0e80746b642 (patch)
tree9d1f9227b49392cdd2edcc01057517da4f4b09c2 /net/unix/af_unix.c
parent3cf29931453215536916d0c4da953fce1911ced3 (diff)
parent520eccdfe187591a51ea9ab4c1a024ae4d0f68d9 (diff)
sync to Linus v4.13-rc2 for subsystem developers to work against
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 6a7fe7660551..7b52a380d710 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(unix_peer_get);
212 212
213static inline void unix_release_addr(struct unix_address *addr) 213static inline void unix_release_addr(struct unix_address *addr)
214{ 214{
215 if (atomic_dec_and_test(&addr->refcnt)) 215 if (refcount_dec_and_test(&addr->refcnt))
216 kfree(addr); 216 kfree(addr);
217} 217}
218 218
@@ -343,7 +343,7 @@ found:
343 * are still connected to it and there's no way to inform "a polling 343 * are still connected to it and there's no way to inform "a polling
344 * implementation" that it should let go of a certain wait queue 344 * implementation" that it should let go of a certain wait queue
345 * 345 *
346 * In order to propagate a wake up, a wait_queue_t of the client 346 * In order to propagate a wake up, a wait_queue_entry_t of the client
347 * socket is enqueued on the peer_wait queue of the server socket 347 * socket is enqueued on the peer_wait queue of the server socket
348 * whose wake function does a wake_up on the ordinary client socket 348 * whose wake function does a wake_up on the ordinary client socket
349 * wait queue. This connection is established whenever a write (or 349 * wait queue. This connection is established whenever a write (or
@@ -352,7 +352,7 @@ found:
352 * was relayed. 352 * was relayed.
353 */ 353 */
354 354
355static int unix_dgram_peer_wake_relay(wait_queue_t *q, unsigned mode, int flags, 355static int unix_dgram_peer_wake_relay(wait_queue_entry_t *q, unsigned mode, int flags,
356 void *key) 356 void *key)
357{ 357{
358 struct unix_sock *u; 358 struct unix_sock *u;
@@ -442,7 +442,7 @@ static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other)
442static int unix_writable(const struct sock *sk) 442static int unix_writable(const struct sock *sk)
443{ 443{
444 return sk->sk_state != TCP_LISTEN && 444 return sk->sk_state != TCP_LISTEN &&
445 (atomic_read(&sk->sk_wmem_alloc) << 2) <= sk->sk_sndbuf; 445 (refcount_read(&sk->sk_wmem_alloc) << 2) <= sk->sk_sndbuf;
446} 446}
447 447
448static void unix_write_space(struct sock *sk) 448static void unix_write_space(struct sock *sk)
@@ -487,7 +487,7 @@ static void unix_sock_destructor(struct sock *sk)
487 487
488 skb_queue_purge(&sk->sk_receive_queue); 488 skb_queue_purge(&sk->sk_receive_queue);
489 489
490 WARN_ON(atomic_read(&sk->sk_wmem_alloc)); 490 WARN_ON(refcount_read(&sk->sk_wmem_alloc));
491 WARN_ON(!sk_unhashed(sk)); 491 WARN_ON(!sk_unhashed(sk));
492 WARN_ON(sk->sk_socket); 492 WARN_ON(sk->sk_socket);
493 if (!sock_flag(sk, SOCK_DEAD)) { 493 if (!sock_flag(sk, SOCK_DEAD)) {
@@ -864,7 +864,7 @@ static int unix_autobind(struct socket *sock)
864 goto out; 864 goto out;
865 865
866 addr->name->sun_family = AF_UNIX; 866 addr->name->sun_family = AF_UNIX;
867 atomic_set(&addr->refcnt, 1); 867 refcount_set(&addr->refcnt, 1);
868 868
869retry: 869retry:
870 addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short); 870 addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short);
@@ -999,7 +999,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
999 struct path path = { }; 999 struct path path = { };
1000 1000
1001 err = -EINVAL; 1001 err = -EINVAL;
1002 if (sunaddr->sun_family != AF_UNIX) 1002 if (addr_len < offsetofend(struct sockaddr_un, sun_family) ||
1003 sunaddr->sun_family != AF_UNIX)
1003 goto out; 1004 goto out;
1004 1005
1005 if (addr_len == sizeof(short)) { 1006 if (addr_len == sizeof(short)) {
@@ -1039,7 +1040,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1039 memcpy(addr->name, sunaddr, addr_len); 1040 memcpy(addr->name, sunaddr, addr_len);
1040 addr->len = addr_len; 1041 addr->len = addr_len;
1041 addr->hash = hash ^ sk->sk_type; 1042 addr->hash = hash ^ sk->sk_type;
1042 atomic_set(&addr->refcnt, 1); 1043 refcount_set(&addr->refcnt, 1);
1043 1044
1044 if (sun_path[0]) { 1045 if (sun_path[0]) {
1045 addr->hash = UNIX_HASH_SIZE; 1046 addr->hash = UNIX_HASH_SIZE;
@@ -1110,6 +1111,10 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
1110 unsigned int hash; 1111 unsigned int hash;
1111 int err; 1112 int err;
1112 1113
1114 err = -EINVAL;
1115 if (alen < offsetofend(struct sockaddr, sa_family))
1116 goto out;
1117
1113 if (addr->sa_family != AF_UNSPEC) { 1118 if (addr->sa_family != AF_UNSPEC) {
1114 err = unix_mkname(sunaddr, alen, &hash); 1119 err = unix_mkname(sunaddr, alen, &hash);
1115 if (err < 0) 1120 if (err < 0)
@@ -1330,7 +1335,7 @@ restart:
1330 1335
1331 /* copy address information from listening to new sock*/ 1336 /* copy address information from listening to new sock*/
1332 if (otheru->addr) { 1337 if (otheru->addr) {
1333 atomic_inc(&otheru->addr->refcnt); 1338 refcount_inc(&otheru->addr->refcnt);
1334 newu->addr = otheru->addr; 1339 newu->addr = otheru->addr;
1335 } 1340 }
1336 if (otheru->path.dentry) { 1341 if (otheru->path.dentry) {
@@ -2028,7 +2033,7 @@ alloc_skb:
2028 skb->len += size; 2033 skb->len += size;
2029 skb->data_len += size; 2034 skb->data_len += size;
2030 skb->truesize += size; 2035 skb->truesize += size;
2031 atomic_add(size, &sk->sk_wmem_alloc); 2036 refcount_add(size, &sk->sk_wmem_alloc);
2032 2037
2033 if (newskb) { 2038 if (newskb) {
2034 err = unix_scm_to_skb(&scm, skb, false); 2039 err = unix_scm_to_skb(&scm, skb, false);
@@ -2842,7 +2847,7 @@ static int unix_seq_show(struct seq_file *seq, void *v)
2842 2847
2843 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu", 2848 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
2844 s, 2849 s,
2845 atomic_read(&s->sk_refcnt), 2850 refcount_read(&s->sk_refcnt),
2846 0, 2851 0,
2847 s->sk_state == TCP_LISTEN ? __SO_ACCEPTCON : 0, 2852 s->sk_state == TCP_LISTEN ? __SO_ACCEPTCON : 0,
2848 s->sk_type, 2853 s->sk_type,