diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-02-23 06:46:49 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-05-01 13:08:50 -0400 |
commit | 2030a42cecd4dd1985a2ab03e25f3cd6106a5ca8 (patch) | |
tree | 7cb4710c3f7a4e034a20890f0df99bc42f9bbcee /fs/eventpoll.c | |
parent | 9f3acc3140444a900ab280de942291959f0f615d (diff) |
[PATCH] sanitize anon_inode_getfd()
a) none of the callers even looks at inode or file returned by anon_inode_getfd()
b) any caller that would try to look at those would be racy, since by the time
it returns we might have raced with close() from another thread and that
file would be pining for fjords.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/eventpoll.c')
-rw-r--r-- | fs/eventpoll.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 221086fef174..990c01d2d66b 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -1050,8 +1050,6 @@ asmlinkage long sys_epoll_create(int size) | |||
1050 | { | 1050 | { |
1051 | int error, fd = -1; | 1051 | int error, fd = -1; |
1052 | struct eventpoll *ep; | 1052 | struct eventpoll *ep; |
1053 | struct inode *inode; | ||
1054 | struct file *file; | ||
1055 | 1053 | ||
1056 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n", | 1054 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n", |
1057 | current, size)); | 1055 | current, size)); |
@@ -1061,29 +1059,24 @@ asmlinkage long sys_epoll_create(int size) | |||
1061 | * structure ( "struct eventpoll" ). | 1059 | * structure ( "struct eventpoll" ). |
1062 | */ | 1060 | */ |
1063 | error = -EINVAL; | 1061 | error = -EINVAL; |
1064 | if (size <= 0 || (error = ep_alloc(&ep)) != 0) | 1062 | if (size <= 0 || (error = ep_alloc(&ep)) < 0) { |
1063 | fd = error; | ||
1065 | goto error_return; | 1064 | goto error_return; |
1065 | } | ||
1066 | 1066 | ||
1067 | /* | 1067 | /* |
1068 | * Creates all the items needed to setup an eventpoll file. That is, | 1068 | * Creates all the items needed to setup an eventpoll file. That is, |
1069 | * a file structure, and inode and a free file descriptor. | 1069 | * a file structure and a free file descriptor. |
1070 | */ | 1070 | */ |
1071 | error = anon_inode_getfd(&fd, &inode, &file, "[eventpoll]", | 1071 | fd = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep); |
1072 | &eventpoll_fops, ep); | 1072 | if (fd < 0) |
1073 | if (error) | 1073 | ep_free(ep); |
1074 | goto error_free; | ||
1075 | 1074 | ||
1075 | error_return: | ||
1076 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", | 1076 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", |
1077 | current, size, fd)); | 1077 | current, size, fd)); |
1078 | 1078 | ||
1079 | return fd; | 1079 | return fd; |
1080 | |||
1081 | error_free: | ||
1082 | ep_free(ep); | ||
1083 | error_return: | ||
1084 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", | ||
1085 | current, size, error)); | ||
1086 | return error; | ||
1087 | } | 1080 | } |
1088 | 1081 | ||
1089 | /* | 1082 | /* |