diff options
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/net/socket.c b/net/socket.c index d163adff95bf..31105f9048a8 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -369,7 +369,7 @@ static int sock_alloc_fd(struct file **filep, int flags) | |||
369 | return fd; | 369 | return fd; |
370 | } | 370 | } |
371 | 371 | ||
372 | static int sock_attach_fd(struct socket *sock, struct file *file) | 372 | static int sock_attach_fd(struct socket *sock, struct file *file, int flags) |
373 | { | 373 | { |
374 | struct dentry *dentry; | 374 | struct dentry *dentry; |
375 | struct qstr name = { .name = "" }; | 375 | struct qstr name = { .name = "" }; |
@@ -391,7 +391,7 @@ static int sock_attach_fd(struct socket *sock, struct file *file) | |||
391 | init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, | 391 | init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, |
392 | &socket_file_ops); | 392 | &socket_file_ops); |
393 | SOCK_INODE(sock)->i_fop = &socket_file_ops; | 393 | SOCK_INODE(sock)->i_fop = &socket_file_ops; |
394 | file->f_flags = O_RDWR; | 394 | file->f_flags = O_RDWR | (flags & O_NONBLOCK); |
395 | file->f_pos = 0; | 395 | file->f_pos = 0; |
396 | file->private_data = sock; | 396 | file->private_data = sock; |
397 | 397 | ||
@@ -404,7 +404,7 @@ int sock_map_fd(struct socket *sock, int flags) | |||
404 | int fd = sock_alloc_fd(&newfile, flags); | 404 | int fd = sock_alloc_fd(&newfile, flags); |
405 | 405 | ||
406 | if (likely(fd >= 0)) { | 406 | if (likely(fd >= 0)) { |
407 | int err = sock_attach_fd(sock, newfile); | 407 | int err = sock_attach_fd(sock, newfile, flags); |
408 | 408 | ||
409 | if (unlikely(err < 0)) { | 409 | if (unlikely(err < 0)) { |
410 | put_filp(newfile); | 410 | put_filp(newfile); |
@@ -1223,7 +1223,7 @@ asmlinkage long sys_socket(int family, int type, int protocol) | |||
1223 | int flags; | 1223 | int flags; |
1224 | 1224 | ||
1225 | flags = type & ~SOCK_TYPE_MASK; | 1225 | flags = type & ~SOCK_TYPE_MASK; |
1226 | if (flags & ~SOCK_CLOEXEC) | 1226 | if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) |
1227 | return -EINVAL; | 1227 | return -EINVAL; |
1228 | type &= SOCK_TYPE_MASK; | 1228 | type &= SOCK_TYPE_MASK; |
1229 | 1229 | ||
@@ -1234,7 +1234,7 @@ asmlinkage long sys_socket(int family, int type, int protocol) | |||
1234 | if (retval < 0) | 1234 | if (retval < 0) |
1235 | goto out; | 1235 | goto out; |
1236 | 1236 | ||
1237 | retval = sock_map_fd(sock, flags & O_CLOEXEC); | 1237 | retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK)); |
1238 | if (retval < 0) | 1238 | if (retval < 0) |
1239 | goto out_release; | 1239 | goto out_release; |
1240 | 1240 | ||
@@ -1260,7 +1260,7 @@ asmlinkage long sys_socketpair(int family, int type, int protocol, | |||
1260 | int flags; | 1260 | int flags; |
1261 | 1261 | ||
1262 | flags = type & ~SOCK_TYPE_MASK; | 1262 | flags = type & ~SOCK_TYPE_MASK; |
1263 | if (flags & ~SOCK_CLOEXEC) | 1263 | if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) |
1264 | return -EINVAL; | 1264 | return -EINVAL; |
1265 | type &= SOCK_TYPE_MASK; | 1265 | type &= SOCK_TYPE_MASK; |
1266 | 1266 | ||
@@ -1298,12 +1298,12 @@ asmlinkage long sys_socketpair(int family, int type, int protocol, | |||
1298 | goto out_release_both; | 1298 | goto out_release_both; |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | err = sock_attach_fd(sock1, newfile1); | 1301 | err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK); |
1302 | if (unlikely(err < 0)) { | 1302 | if (unlikely(err < 0)) { |
1303 | goto out_fd2; | 1303 | goto out_fd2; |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | err = sock_attach_fd(sock2, newfile2); | 1306 | err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK); |
1307 | if (unlikely(err < 0)) { | 1307 | if (unlikely(err < 0)) { |
1308 | fput(newfile1); | 1308 | fput(newfile1); |
1309 | goto out_fd1; | 1309 | goto out_fd1; |
@@ -1429,7 +1429,7 @@ long do_accept(int fd, struct sockaddr __user *upeer_sockaddr, | |||
1429 | int err, len, newfd, fput_needed; | 1429 | int err, len, newfd, fput_needed; |
1430 | struct sockaddr_storage address; | 1430 | struct sockaddr_storage address; |
1431 | 1431 | ||
1432 | if (flags & ~SOCK_CLOEXEC) | 1432 | if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) |
1433 | return -EINVAL; | 1433 | return -EINVAL; |
1434 | 1434 | ||
1435 | if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) | 1435 | if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) |
@@ -1459,7 +1459,7 @@ long do_accept(int fd, struct sockaddr __user *upeer_sockaddr, | |||
1459 | goto out_put; | 1459 | goto out_put; |
1460 | } | 1460 | } |
1461 | 1461 | ||
1462 | err = sock_attach_fd(newsock, newfile); | 1462 | err = sock_attach_fd(newsock, newfile, flags & O_NONBLOCK); |
1463 | if (err < 0) | 1463 | if (err < 0) |
1464 | goto out_fd_simple; | 1464 | goto out_fd_simple; |
1465 | 1465 | ||