aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 94404f19f9de..e96884380732 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1207,7 +1207,7 @@ restart:
1207 sk->sk_state = TCP_ESTABLISHED; 1207 sk->sk_state = TCP_ESTABLISHED;
1208 sock_hold(newsk); 1208 sock_hold(newsk);
1209 1209
1210 smp_mb__after_atomic_inc(); /* sock_hold() does an atomic_inc() */ 1210 smp_mb__after_atomic(); /* sock_hold() does an atomic_inc() */
1211 unix_peer(sk) = newsk; 1211 unix_peer(sk) = newsk;
1212 1212
1213 unix_state_unlock(sk); 1213 unix_state_unlock(sk);
@@ -1217,7 +1217,7 @@ restart:
1217 __skb_queue_tail(&other->sk_receive_queue, skb); 1217 __skb_queue_tail(&other->sk_receive_queue, skb);
1218 spin_unlock(&other->sk_receive_queue.lock); 1218 spin_unlock(&other->sk_receive_queue.lock);
1219 unix_state_unlock(other); 1219 unix_state_unlock(other);
1220 other->sk_data_ready(other, 0); 1220 other->sk_data_ready(other);
1221 sock_put(other); 1221 sock_put(other);
1222 return 0; 1222 return 0;
1223 1223
@@ -1492,10 +1492,14 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1492 if (len > sk->sk_sndbuf - 32) 1492 if (len > sk->sk_sndbuf - 32)
1493 goto out; 1493 goto out;
1494 1494
1495 if (len > SKB_MAX_ALLOC) 1495 if (len > SKB_MAX_ALLOC) {
1496 data_len = min_t(size_t, 1496 data_len = min_t(size_t,
1497 len - SKB_MAX_ALLOC, 1497 len - SKB_MAX_ALLOC,
1498 MAX_SKB_FRAGS * PAGE_SIZE); 1498 MAX_SKB_FRAGS * PAGE_SIZE);
1499 data_len = PAGE_ALIGN(data_len);
1500
1501 BUILD_BUG_ON(SKB_MAX_ALLOC < PAGE_SIZE);
1502 }
1499 1503
1500 skb = sock_alloc_send_pskb(sk, len - data_len, data_len, 1504 skb = sock_alloc_send_pskb(sk, len - data_len, data_len,
1501 msg->msg_flags & MSG_DONTWAIT, &err, 1505 msg->msg_flags & MSG_DONTWAIT, &err,
@@ -1600,7 +1604,7 @@ restart:
1600 if (max_level > unix_sk(other)->recursion_level) 1604 if (max_level > unix_sk(other)->recursion_level)
1601 unix_sk(other)->recursion_level = max_level; 1605 unix_sk(other)->recursion_level = max_level;
1602 unix_state_unlock(other); 1606 unix_state_unlock(other);
1603 other->sk_data_ready(other, len); 1607 other->sk_data_ready(other);
1604 sock_put(other); 1608 sock_put(other);
1605 scm_destroy(siocb->scm); 1609 scm_destroy(siocb->scm);
1606 return len; 1610 return len;
@@ -1670,6 +1674,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1670 1674
1671 data_len = max_t(int, 0, size - SKB_MAX_HEAD(0)); 1675 data_len = max_t(int, 0, size - SKB_MAX_HEAD(0));
1672 1676
1677 data_len = min_t(size_t, size, PAGE_ALIGN(data_len));
1678
1673 skb = sock_alloc_send_pskb(sk, size - data_len, data_len, 1679 skb = sock_alloc_send_pskb(sk, size - data_len, data_len,
1674 msg->msg_flags & MSG_DONTWAIT, &err, 1680 msg->msg_flags & MSG_DONTWAIT, &err,
1675 get_order(UNIX_SKB_FRAGS_SZ)); 1681 get_order(UNIX_SKB_FRAGS_SZ));
@@ -1706,7 +1712,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1706 if (max_level > unix_sk(other)->recursion_level) 1712 if (max_level > unix_sk(other)->recursion_level)
1707 unix_sk(other)->recursion_level = max_level; 1713 unix_sk(other)->recursion_level = max_level;
1708 unix_state_unlock(other); 1714 unix_state_unlock(other);
1709 other->sk_data_ready(other, size); 1715 other->sk_data_ready(other);
1710 sent += size; 1716 sent += size;
1711 } 1717 }
1712 1718