aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-19 13:29:54 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-19 13:29:54 -0800
commitcb4aaf46c0283dd79ab2e8b8b165c0bf13ab6194 (patch)
tree2e01de06d4740300cfcfbb9e9f9fd3b7078dd3ce /net
parent874ff01bd9183ad16495acfd54e93a619d12b8b5 (diff)
parentdb3495099d3d52854b13874905af6e40a91f4721 (diff)
Merge branch 'audit.b37' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current
* 'audit.b37' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current: [PATCH] AUDIT_FD_PAIR [PATCH] audit config lockdown [PATCH] minor update to rule add/delete messages (ver 2)
Diffstat (limited to 'net')
-rw-r--r--net/socket.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/net/socket.c b/net/socket.c
index 0778c544241..9566e57ac7f 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1194,6 +1194,7 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
{
struct socket *sock1, *sock2;
int fd1, fd2, err;
+ struct file *newfile1, *newfile2;
/*
* Obtain the first socket and check if the underlying protocol
@@ -1212,18 +1213,37 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
if (err < 0)
goto out_release_both;
- fd1 = fd2 = -1;
+ fd1 = sock_alloc_fd(&newfile1);
+ if (unlikely(fd1 < 0))
+ goto out_release_both;
- err = sock_map_fd(sock1);
- if (err < 0)
+ fd2 = sock_alloc_fd(&newfile2);
+ if (unlikely(fd2 < 0)) {
+ put_filp(newfile1);
+ put_unused_fd(fd1);
goto out_release_both;
- fd1 = err;
+ }
- err = sock_map_fd(sock2);
- if (err < 0)
- goto out_close_1;
- fd2 = err;
+ err = sock_attach_fd(sock1, newfile1);
+ if (unlikely(err < 0)) {
+ goto out_fd2;
+ }
+
+ err = sock_attach_fd(sock2, newfile2);
+ if (unlikely(err < 0)) {
+ fput(newfile1);
+ goto out_fd1;
+ }
+
+ err = audit_fd_pair(fd1, fd2);
+ if (err < 0) {
+ fput(newfile1);
+ fput(newfile2);
+ goto out_fd;
+ }
+ fd_install(fd1, newfile1);
+ fd_install(fd2, newfile2);
/* fd1 and fd2 may be already another descriptors.
* Not kernel problem.
*/
@@ -1238,17 +1258,23 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
sys_close(fd1);
return err;
-out_close_1:
- sock_release(sock2);
- sys_close(fd1);
- return err;
-
out_release_both:
sock_release(sock2);
out_release_1:
sock_release(sock1);
out:
return err;
+
+out_fd2:
+ put_filp(newfile1);
+ sock_release(sock1);
+out_fd1:
+ put_filp(newfile2);
+ sock_release(sock2);
+out_fd:
+ put_unused_fd(fd1);
+ put_unused_fd(fd2);
+ goto out;
}
/*