Skip to content

Commit

Permalink
[NET]: Correct accept(2) recovery after sock_attach_fd()
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Alexey Dobriyan authored and David S. Miller committed Mar 26, 2007
1 parent 165de5b commit 79f4f64
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,

err = sock_attach_fd(newsock, newfile);
if (err < 0)
goto out_fd;
goto out_fd_simple;

err = security_socket_accept(sock, newsock);
if (err)
Expand Down Expand Up @@ -1414,6 +1414,11 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
fput_light(sock->file, fput_needed);
out:
return err;
out_fd_simple:
sock_release(newsock);
put_filp(newfile);
put_unused_fd(newfd);
goto out_put;
out_fd:
fput(newfile);
put_unused_fd(newfd);
Expand Down

0 comments on commit 79f4f64

Please sign in to comment.