diff options
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r-- | net/unix/af_unix.c | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 0214acbd6bff..68bb70a62afe 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -415,9 +415,9 @@ static void unix_dgram_peer_wake_disconnect_wakeup(struct sock *sk, | |||
415 | { | 415 | { |
416 | unix_dgram_peer_wake_disconnect(sk, other); | 416 | unix_dgram_peer_wake_disconnect(sk, other); |
417 | wake_up_interruptible_poll(sk_sleep(sk), | 417 | wake_up_interruptible_poll(sk_sleep(sk), |
418 | POLLOUT | | 418 | EPOLLOUT | |
419 | POLLWRNORM | | 419 | EPOLLWRNORM | |
420 | POLLWRBAND); | 420 | EPOLLWRBAND); |
421 | } | 421 | } |
422 | 422 | ||
423 | /* preconditions: | 423 | /* preconditions: |
@@ -454,7 +454,7 @@ static void unix_write_space(struct sock *sk) | |||
454 | wq = rcu_dereference(sk->sk_wq); | 454 | wq = rcu_dereference(sk->sk_wq); |
455 | if (skwq_has_sleeper(wq)) | 455 | if (skwq_has_sleeper(wq)) |
456 | wake_up_interruptible_sync_poll(&wq->wait, | 456 | wake_up_interruptible_sync_poll(&wq->wait, |
457 | POLLOUT | POLLWRNORM | POLLWRBAND); | 457 | EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND); |
458 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); | 458 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); |
459 | } | 459 | } |
460 | rcu_read_unlock(); | 460 | rcu_read_unlock(); |
@@ -637,7 +637,7 @@ static int unix_stream_connect(struct socket *, struct sockaddr *, | |||
637 | int addr_len, int flags); | 637 | int addr_len, int flags); |
638 | static int unix_socketpair(struct socket *, struct socket *); | 638 | static int unix_socketpair(struct socket *, struct socket *); |
639 | static int unix_accept(struct socket *, struct socket *, int, bool); | 639 | static int unix_accept(struct socket *, struct socket *, int, bool); |
640 | static int unix_getname(struct socket *, struct sockaddr *, int *, int); | 640 | static int unix_getname(struct socket *, struct sockaddr *, int); |
641 | static __poll_t unix_poll(struct file *, struct socket *, poll_table *); | 641 | static __poll_t unix_poll(struct file *, struct socket *, poll_table *); |
642 | static __poll_t unix_dgram_poll(struct file *, struct socket *, | 642 | static __poll_t unix_dgram_poll(struct file *, struct socket *, |
643 | poll_table *); | 643 | poll_table *); |
@@ -745,14 +745,6 @@ static struct proto unix_proto = { | |||
745 | .obj_size = sizeof(struct unix_sock), | 745 | .obj_size = sizeof(struct unix_sock), |
746 | }; | 746 | }; |
747 | 747 | ||
748 | /* | ||
749 | * AF_UNIX sockets do not interact with hardware, hence they | ||
750 | * dont trigger interrupts - so it's safe for them to have | ||
751 | * bh-unsafe locking for their sk_receive_queue.lock. Split off | ||
752 | * this special lock-class by reinitializing the spinlock key: | ||
753 | */ | ||
754 | static struct lock_class_key af_unix_sk_receive_queue_lock_key; | ||
755 | |||
756 | static struct sock *unix_create1(struct net *net, struct socket *sock, int kern) | 748 | static struct sock *unix_create1(struct net *net, struct socket *sock, int kern) |
757 | { | 749 | { |
758 | struct sock *sk = NULL; | 750 | struct sock *sk = NULL; |
@@ -767,8 +759,6 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern) | |||
767 | goto out; | 759 | goto out; |
768 | 760 | ||
769 | sock_init_data(sock, sk); | 761 | sock_init_data(sock, sk); |
770 | lockdep_set_class(&sk->sk_receive_queue.lock, | ||
771 | &af_unix_sk_receive_queue_lock_key); | ||
772 | 762 | ||
773 | sk->sk_allocation = GFP_KERNEL_ACCOUNT; | 763 | sk->sk_allocation = GFP_KERNEL_ACCOUNT; |
774 | sk->sk_write_space = unix_write_space; | 764 | sk->sk_write_space = unix_write_space; |
@@ -1453,7 +1443,7 @@ out: | |||
1453 | } | 1443 | } |
1454 | 1444 | ||
1455 | 1445 | ||
1456 | static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer) | 1446 | static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int peer) |
1457 | { | 1447 | { |
1458 | struct sock *sk = sock->sk; | 1448 | struct sock *sk = sock->sk; |
1459 | struct unix_sock *u; | 1449 | struct unix_sock *u; |
@@ -1476,12 +1466,12 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_ | |||
1476 | if (!u->addr) { | 1466 | if (!u->addr) { |
1477 | sunaddr->sun_family = AF_UNIX; | 1467 | sunaddr->sun_family = AF_UNIX; |
1478 | sunaddr->sun_path[0] = 0; | 1468 | sunaddr->sun_path[0] = 0; |
1479 | *uaddr_len = sizeof(short); | 1469 | err = sizeof(short); |
1480 | } else { | 1470 | } else { |
1481 | struct unix_address *addr = u->addr; | 1471 | struct unix_address *addr = u->addr; |
1482 | 1472 | ||
1483 | *uaddr_len = addr->len; | 1473 | err = addr->len; |
1484 | memcpy(sunaddr, addr->name, *uaddr_len); | 1474 | memcpy(sunaddr, addr->name, addr->len); |
1485 | } | 1475 | } |
1486 | unix_state_unlock(sk); | 1476 | unix_state_unlock(sk); |
1487 | sock_put(sk); | 1477 | sock_put(sk); |
@@ -1825,7 +1815,7 @@ out: | |||
1825 | } | 1815 | } |
1826 | 1816 | ||
1827 | /* We use paged skbs for stream sockets, and limit occupancy to 32768 | 1817 | /* We use paged skbs for stream sockets, and limit occupancy to 32768 |
1828 | * bytes, and a minimun of a full page. | 1818 | * bytes, and a minimum of a full page. |
1829 | */ | 1819 | */ |
1830 | #define UNIX_SKB_FRAGS_SZ (PAGE_SIZE << get_order(32768)) | 1820 | #define UNIX_SKB_FRAGS_SZ (PAGE_SIZE << get_order(32768)) |
1831 | 1821 | ||
@@ -2129,8 +2119,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, | |||
2129 | 2119 | ||
2130 | if (wq_has_sleeper(&u->peer_wait)) | 2120 | if (wq_has_sleeper(&u->peer_wait)) |
2131 | wake_up_interruptible_sync_poll(&u->peer_wait, | 2121 | wake_up_interruptible_sync_poll(&u->peer_wait, |
2132 | POLLOUT | POLLWRNORM | | 2122 | EPOLLOUT | EPOLLWRNORM | |
2133 | POLLWRBAND); | 2123 | EPOLLWRBAND); |
2134 | 2124 | ||
2135 | if (msg->msg_name) | 2125 | if (msg->msg_name) |
2136 | unix_copy_addr(msg, skb->sk); | 2126 | unix_copy_addr(msg, skb->sk); |
@@ -2650,27 +2640,27 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa | |||
2650 | 2640 | ||
2651 | /* exceptional events? */ | 2641 | /* exceptional events? */ |
2652 | if (sk->sk_err) | 2642 | if (sk->sk_err) |
2653 | mask |= POLLERR; | 2643 | mask |= EPOLLERR; |
2654 | if (sk->sk_shutdown == SHUTDOWN_MASK) | 2644 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
2655 | mask |= POLLHUP; | 2645 | mask |= EPOLLHUP; |
2656 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 2646 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
2657 | mask |= POLLRDHUP | POLLIN | POLLRDNORM; | 2647 | mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM; |
2658 | 2648 | ||
2659 | /* readable? */ | 2649 | /* readable? */ |
2660 | if (!skb_queue_empty(&sk->sk_receive_queue)) | 2650 | if (!skb_queue_empty(&sk->sk_receive_queue)) |
2661 | mask |= POLLIN | POLLRDNORM; | 2651 | mask |= EPOLLIN | EPOLLRDNORM; |
2662 | 2652 | ||
2663 | /* Connection-based need to check for termination and startup */ | 2653 | /* Connection-based need to check for termination and startup */ |
2664 | if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && | 2654 | if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && |
2665 | sk->sk_state == TCP_CLOSE) | 2655 | sk->sk_state == TCP_CLOSE) |
2666 | mask |= POLLHUP; | 2656 | mask |= EPOLLHUP; |
2667 | 2657 | ||
2668 | /* | 2658 | /* |
2669 | * we set writable also when the other side has shut down the | 2659 | * we set writable also when the other side has shut down the |
2670 | * connection. This prevents stuck sockets. | 2660 | * connection. This prevents stuck sockets. |
2671 | */ | 2661 | */ |
2672 | if (unix_writable(sk)) | 2662 | if (unix_writable(sk)) |
2673 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; | 2663 | mask |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND; |
2674 | 2664 | ||
2675 | return mask; | 2665 | return mask; |
2676 | } | 2666 | } |
@@ -2687,29 +2677,29 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock, | |||
2687 | 2677 | ||
2688 | /* exceptional events? */ | 2678 | /* exceptional events? */ |
2689 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) | 2679 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) |
2690 | mask |= POLLERR | | 2680 | mask |= EPOLLERR | |
2691 | (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); | 2681 | (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); |
2692 | 2682 | ||
2693 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 2683 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
2694 | mask |= POLLRDHUP | POLLIN | POLLRDNORM; | 2684 | mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM; |
2695 | if (sk->sk_shutdown == SHUTDOWN_MASK) | 2685 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
2696 | mask |= POLLHUP; | 2686 | mask |= EPOLLHUP; |
2697 | 2687 | ||
2698 | /* readable? */ | 2688 | /* readable? */ |
2699 | if (!skb_queue_empty(&sk->sk_receive_queue)) | 2689 | if (!skb_queue_empty(&sk->sk_receive_queue)) |
2700 | mask |= POLLIN | POLLRDNORM; | 2690 | mask |= EPOLLIN | EPOLLRDNORM; |
2701 | 2691 | ||
2702 | /* Connection-based need to check for termination and startup */ | 2692 | /* Connection-based need to check for termination and startup */ |
2703 | if (sk->sk_type == SOCK_SEQPACKET) { | 2693 | if (sk->sk_type == SOCK_SEQPACKET) { |
2704 | if (sk->sk_state == TCP_CLOSE) | 2694 | if (sk->sk_state == TCP_CLOSE) |
2705 | mask |= POLLHUP; | 2695 | mask |= EPOLLHUP; |
2706 | /* connection hasn't started yet? */ | 2696 | /* connection hasn't started yet? */ |
2707 | if (sk->sk_state == TCP_SYN_SENT) | 2697 | if (sk->sk_state == TCP_SYN_SENT) |
2708 | return mask; | 2698 | return mask; |
2709 | } | 2699 | } |
2710 | 2700 | ||
2711 | /* No write status requested, avoid expensive OUT tests. */ | 2701 | /* No write status requested, avoid expensive OUT tests. */ |
2712 | if (!(poll_requested_events(wait) & (POLLWRBAND|POLLWRNORM|POLLOUT))) | 2702 | if (!(poll_requested_events(wait) & (EPOLLWRBAND|EPOLLWRNORM|EPOLLOUT))) |
2713 | return mask; | 2703 | return mask; |
2714 | 2704 | ||
2715 | writable = unix_writable(sk); | 2705 | writable = unix_writable(sk); |
@@ -2726,7 +2716,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock, | |||
2726 | } | 2716 | } |
2727 | 2717 | ||
2728 | if (writable) | 2718 | if (writable) |
2729 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; | 2719 | mask |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND; |
2730 | else | 2720 | else |
2731 | sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); | 2721 | sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); |
2732 | 2722 | ||