diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2007-03-26 17:09:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-03-26 17:09:52 -0400 |
commit | 79f4f6428f6ceb9af57330092271bda028c23a96 (patch) | |
tree | e73a452517b3e6f8cc5c583a3e0174b039ccc5a2 /net/socket.c | |
parent | 165de5b7f2719c1984956504128545839762d635 (diff) |
[NET]: Correct accept(2) recovery after sock_attach_fd()
* d_alloc() in sock_attach_fd() fails leaving ->f_dentry of new file NULL
* bail out to out_fd label, doing fput()/__fput() on new file
* but __fput() assumes valid ->f_dentry and dereferences it
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/socket.c b/net/socket.c index 9566e57ac7f5..ea8f81abc45c 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -1381,7 +1381,7 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, | |||
1381 | 1381 | ||
1382 | err = sock_attach_fd(newsock, newfile); | 1382 | err = sock_attach_fd(newsock, newfile); |
1383 | if (err < 0) | 1383 | if (err < 0) |
1384 | goto out_fd; | 1384 | goto out_fd_simple; |
1385 | 1385 | ||
1386 | err = security_socket_accept(sock, newsock); | 1386 | err = security_socket_accept(sock, newsock); |
1387 | if (err) | 1387 | if (err) |
@@ -1414,6 +1414,11 @@ out_put: | |||
1414 | fput_light(sock->file, fput_needed); | 1414 | fput_light(sock->file, fput_needed); |
1415 | out: | 1415 | out: |
1416 | return err; | 1416 | return err; |
1417 | out_fd_simple: | ||
1418 | sock_release(newsock); | ||
1419 | put_filp(newfile); | ||
1420 | put_unused_fd(newfd); | ||
1421 | goto out_put; | ||
1417 | out_fd: | 1422 | out_fd: |
1418 | fput(newfile); | 1423 | fput(newfile); |
1419 | put_unused_fd(newfd); | 1424 | put_unused_fd(newfd); |