aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-11 05:31:07 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-11 05:31:07 -0400
commit9e9fd65d1fa51d919d54d731be0e66492b5b6c5a (patch)
treea1c7bd35ccff62ff2e678514d3599110f18f113a /net/unix/af_unix.c
parent05644147064acabb8587c4cbd690047494f7b3a1 (diff)
parent5b063b87deba33ed1676db9d16c52ede662132d8 (diff)
Merge branch 'pl022' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson into spi-next
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index d510353ef431..641f2e47f165 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -149,9 +149,10 @@ static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb)
149 * each socket state is protected by separate spin lock. 149 * each socket state is protected by separate spin lock.
150 */ 150 */
151 151
152static inline unsigned unix_hash_fold(__wsum n) 152static inline unsigned int unix_hash_fold(__wsum n)
153{ 153{
154 unsigned hash = (__force unsigned)n; 154 unsigned int hash = (__force unsigned int)n;
155
155 hash ^= hash>>16; 156 hash ^= hash>>16;
156 hash ^= hash>>8; 157 hash ^= hash>>8;
157 return hash&(UNIX_HASH_SIZE-1); 158 return hash&(UNIX_HASH_SIZE-1);
@@ -200,7 +201,7 @@ static inline void unix_release_addr(struct unix_address *addr)
200 * - if started by zero, it is abstract name. 201 * - if started by zero, it is abstract name.
201 */ 202 */
202 203
203static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned *hashp) 204static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned int *hashp)
204{ 205{
205 if (len <= sizeof(short) || len > sizeof(*sunaddr)) 206 if (len <= sizeof(short) || len > sizeof(*sunaddr))
206 return -EINVAL; 207 return -EINVAL;
@@ -250,7 +251,7 @@ static inline void unix_insert_socket(struct hlist_head *list, struct sock *sk)
250 251
251static struct sock *__unix_find_socket_byname(struct net *net, 252static struct sock *__unix_find_socket_byname(struct net *net,
252 struct sockaddr_un *sunname, 253 struct sockaddr_un *sunname,
253 int len, int type, unsigned hash) 254 int len, int type, unsigned int hash)
254{ 255{
255 struct sock *s; 256 struct sock *s;
256 struct hlist_node *node; 257 struct hlist_node *node;
@@ -273,7 +274,7 @@ found:
273static inline struct sock *unix_find_socket_byname(struct net *net, 274static inline struct sock *unix_find_socket_byname(struct net *net,
274 struct sockaddr_un *sunname, 275 struct sockaddr_un *sunname,
275 int len, int type, 276 int len, int type,
276 unsigned hash) 277 unsigned int hash)
277{ 278{
278 struct sock *s; 279 struct sock *s;
279 280
@@ -760,7 +761,7 @@ out: mutex_unlock(&u->readlock);
760 761
761static struct sock *unix_find_other(struct net *net, 762static struct sock *unix_find_other(struct net *net,
762 struct sockaddr_un *sunname, int len, 763 struct sockaddr_un *sunname, int len,
763 int type, unsigned hash, int *error) 764 int type, unsigned int hash, int *error)
764{ 765{
765 struct sock *u; 766 struct sock *u;
766 struct path path; 767 struct path path;
@@ -824,7 +825,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
824 struct dentry *dentry = NULL; 825 struct dentry *dentry = NULL;
825 struct path path; 826 struct path path;
826 int err; 827 int err;
827 unsigned hash; 828 unsigned int hash;
828 struct unix_address *addr; 829 struct unix_address *addr;
829 struct hlist_head *list; 830 struct hlist_head *list;
830 831
@@ -964,7 +965,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
964 struct net *net = sock_net(sk); 965 struct net *net = sock_net(sk);
965 struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr; 966 struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;
966 struct sock *other; 967 struct sock *other;
967 unsigned hash; 968 unsigned int hash;
968 int err; 969 int err;
969 970
970 if (addr->sa_family != AF_UNSPEC) { 971 if (addr->sa_family != AF_UNSPEC) {
@@ -1062,7 +1063,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
1062 struct sock *newsk = NULL; 1063 struct sock *newsk = NULL;
1063 struct sock *other = NULL; 1064 struct sock *other = NULL;
1064 struct sk_buff *skb = NULL; 1065 struct sk_buff *skb = NULL;
1065 unsigned hash; 1066 unsigned int hash;
1066 int st; 1067 int st;
1067 int err; 1068 int err;
1068 long timeo; 1069 long timeo;
@@ -1437,11 +1438,12 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1437 struct sock *other = NULL; 1438 struct sock *other = NULL;
1438 int namelen = 0; /* fake GCC */ 1439 int namelen = 0; /* fake GCC */
1439 int err; 1440 int err;
1440 unsigned hash; 1441 unsigned int hash;
1441 struct sk_buff *skb; 1442 struct sk_buff *skb;
1442 long timeo; 1443 long timeo;
1443 struct scm_cookie tmp_scm; 1444 struct scm_cookie tmp_scm;
1444 int max_level; 1445 int max_level;
1446 int data_len = 0;
1445 1447
1446 if (NULL == siocb->scm) 1448 if (NULL == siocb->scm)
1447 siocb->scm = &tmp_scm; 1449 siocb->scm = &tmp_scm;
@@ -1475,7 +1477,13 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1475 if (len > sk->sk_sndbuf - 32) 1477 if (len > sk->sk_sndbuf - 32)
1476 goto out; 1478 goto out;
1477 1479
1478 skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err); 1480 if (len > SKB_MAX_ALLOC)
1481 data_len = min_t(size_t,
1482 len - SKB_MAX_ALLOC,
1483 MAX_SKB_FRAGS * PAGE_SIZE);
1484
1485 skb = sock_alloc_send_pskb(sk, len - data_len, data_len,
1486 msg->msg_flags & MSG_DONTWAIT, &err);
1479 if (skb == NULL) 1487 if (skb == NULL)
1480 goto out; 1488 goto out;
1481 1489
@@ -1485,8 +1493,10 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1485 max_level = err + 1; 1493 max_level = err + 1;
1486 unix_get_secdata(siocb->scm, skb); 1494 unix_get_secdata(siocb->scm, skb);
1487 1495
1488 skb_reset_transport_header(skb); 1496 skb_put(skb, len - data_len);
1489 err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); 1497 skb->data_len = data_len;
1498 skb->len = len;
1499 err = skb_copy_datagram_from_iovec(skb, 0, msg->msg_iov, 0, len);
1490 if (err) 1500 if (err)
1491 goto out_free; 1501 goto out_free;
1492 1502