@@ -603,7 +603,7 @@ static void unix_release_sock(struct sock *sk, int embrion)
603603 /* Clear state */
604604 unix_state_lock (sk );
605605 sock_orphan (sk );
606- sk -> sk_shutdown = SHUTDOWN_MASK ;
606+ WRITE_ONCE ( sk -> sk_shutdown , SHUTDOWN_MASK ) ;
607607 path = u -> path ;
608608 u -> path .dentry = NULL ;
609609 u -> path .mnt = NULL ;
@@ -628,7 +628,7 @@ static void unix_release_sock(struct sock *sk, int embrion)
628628 if (sk -> sk_type == SOCK_STREAM || sk -> sk_type == SOCK_SEQPACKET ) {
629629 unix_state_lock (skpair );
630630 /* No more writes */
631- skpair -> sk_shutdown = SHUTDOWN_MASK ;
631+ WRITE_ONCE ( skpair -> sk_shutdown , SHUTDOWN_MASK ) ;
632632 if (!skb_queue_empty (& sk -> sk_receive_queue ) || embrion )
633633 WRITE_ONCE (skpair -> sk_err , ECONNRESET );
634634 unix_state_unlock (skpair );
@@ -1442,7 +1442,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo)
14421442
14431443 sched = !sock_flag (other , SOCK_DEAD ) &&
14441444 !(other -> sk_shutdown & RCV_SHUTDOWN ) &&
1445- unix_recvq_full (other );
1445+ unix_recvq_full_lockless (other );
14461446
14471447 unix_state_unlock (other );
14481448
@@ -3008,7 +3008,7 @@ static int unix_shutdown(struct socket *sock, int mode)
30083008 ++ mode ;
30093009
30103010 unix_state_lock (sk );
3011- sk -> sk_shutdown |= mode ;
3011+ WRITE_ONCE ( sk -> sk_shutdown , sk -> sk_shutdown | mode ) ;
30123012 other = unix_peer (sk );
30133013 if (other )
30143014 sock_hold (other );
@@ -3028,7 +3028,7 @@ static int unix_shutdown(struct socket *sock, int mode)
30283028 if (mode & SEND_SHUTDOWN )
30293029 peer_mode |= RCV_SHUTDOWN ;
30303030 unix_state_lock (other );
3031- other -> sk_shutdown |= peer_mode ;
3031+ WRITE_ONCE ( other -> sk_shutdown , other -> sk_shutdown | peer_mode ) ;
30323032 unix_state_unlock (other );
30333033 other -> sk_state_change (other );
30343034 if (peer_mode == SHUTDOWN_MASK )
@@ -3160,16 +3160,18 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
31603160{
31613161 struct sock * sk = sock -> sk ;
31623162 __poll_t mask ;
3163+ u8 shutdown ;
31633164
31643165 sock_poll_wait (file , sock , wait );
31653166 mask = 0 ;
3167+ shutdown = READ_ONCE (sk -> sk_shutdown );
31663168
31673169 /* exceptional events? */
31683170 if (READ_ONCE (sk -> sk_err ))
31693171 mask |= EPOLLERR ;
3170- if (sk -> sk_shutdown == SHUTDOWN_MASK )
3172+ if (shutdown == SHUTDOWN_MASK )
31713173 mask |= EPOLLHUP ;
3172- if (sk -> sk_shutdown & RCV_SHUTDOWN )
3174+ if (shutdown & RCV_SHUTDOWN )
31733175 mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM ;
31743176
31753177 /* readable? */
@@ -3203,19 +3205,21 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
32033205 struct sock * sk = sock -> sk , * other ;
32043206 unsigned int writable ;
32053207 __poll_t mask ;
3208+ u8 shutdown ;
32063209
32073210 sock_poll_wait (file , sock , wait );
32083211 mask = 0 ;
3212+ shutdown = READ_ONCE (sk -> sk_shutdown );
32093213
32103214 /* exceptional events? */
32113215 if (READ_ONCE (sk -> sk_err ) ||
32123216 !skb_queue_empty_lockless (& sk -> sk_error_queue ))
32133217 mask |= EPOLLERR |
32143218 (sock_flag (sk , SOCK_SELECT_ERR_QUEUE ) ? EPOLLPRI : 0 );
32153219
3216- if (sk -> sk_shutdown & RCV_SHUTDOWN )
3220+ if (shutdown & RCV_SHUTDOWN )
32173221 mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM ;
3218- if (sk -> sk_shutdown == SHUTDOWN_MASK )
3222+ if (shutdown == SHUTDOWN_MASK )
32193223 mask |= EPOLLHUP ;
32203224
32213225 /* readable? */
0 commit comments