aboutsummaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/net/socket.c b/net/socket.c
index c699e93c33d7..3145103cdf54 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1145,8 +1145,11 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
1145 if (!try_module_get(net_families[family]->owner)) 1145 if (!try_module_get(net_families[family]->owner))
1146 goto out_release; 1146 goto out_release;
1147 1147
1148 if ((err = net_families[family]->create(sock, protocol)) < 0) 1148 if ((err = net_families[family]->create(sock, protocol)) < 0) {
1149 sock->ops = NULL;
1149 goto out_module_put; 1150 goto out_module_put;
1151 }
1152
1150 /* 1153 /*
1151 * Now to bump the refcnt of the [loadable] module that owns this 1154 * Now to bump the refcnt of the [loadable] module that owns this
1152 * socket at sock_release time we decrement its refcnt. 1155 * socket at sock_release time we decrement its refcnt.
@@ -1360,16 +1363,16 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int _
1360 newsock->type = sock->type; 1363 newsock->type = sock->type;
1361 newsock->ops = sock->ops; 1364 newsock->ops = sock->ops;
1362 1365
1363 err = security_socket_accept(sock, newsock);
1364 if (err)
1365 goto out_release;
1366
1367 /* 1366 /*
1368 * We don't need try_module_get here, as the listening socket (sock) 1367 * We don't need try_module_get here, as the listening socket (sock)
1369 * has the protocol module (sock->ops->owner) held. 1368 * has the protocol module (sock->ops->owner) held.
1370 */ 1369 */
1371 __module_get(newsock->ops->owner); 1370 __module_get(newsock->ops->owner);
1372 1371
1372 err = security_socket_accept(sock, newsock);
1373 if (err)
1374 goto out_release;
1375
1373 err = sock->ops->accept(sock, newsock, sock->file->f_flags); 1376 err = sock->ops->accept(sock, newsock, sock->file->f_flags);
1374 if (err < 0) 1377 if (err < 0)
1375 goto out_release; 1378 goto out_release;
@@ -1700,7 +1703,9 @@ asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags)
1700 struct socket *sock; 1703 struct socket *sock;
1701 char address[MAX_SOCK_ADDR]; 1704 char address[MAX_SOCK_ADDR];
1702 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; 1705 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
1703 unsigned char ctl[sizeof(struct cmsghdr) + 20]; /* 20 is size of ipv6_pktinfo */ 1706 unsigned char ctl[sizeof(struct cmsghdr) + 20]
1707 __attribute__ ((aligned (sizeof(__kernel_size_t))));
1708 /* 20 is size of ipv6_pktinfo */
1704 unsigned char *ctl_buf = ctl; 1709 unsigned char *ctl_buf = ctl;
1705 struct msghdr msg_sys; 1710 struct msghdr msg_sys;
1706 int err, ctl_len, iov_size, total_len; 1711 int err, ctl_len, iov_size, total_len;
@@ -1862,7 +1867,8 @@ asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, unsigned int flag
1862 if (err < 0) 1867 if (err < 0)
1863 goto out_freeiov; 1868 goto out_freeiov;
1864 } 1869 }
1865 err = __put_user(msg_sys.msg_flags, COMPAT_FLAGS(msg)); 1870 err = __put_user((msg_sys.msg_flags & ~MSG_CMSG_COMPAT),
1871 COMPAT_FLAGS(msg));
1866 if (err) 1872 if (err)
1867 goto out_freeiov; 1873 goto out_freeiov;
1868 if (MSG_CMSG_COMPAT & flags) 1874 if (MSG_CMSG_COMPAT & flags)