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/eventfd.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/eventfd.c')
-rw-r--r-- | fs/eventfd.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/fs/eventfd.c b/fs/eventfd.c index a9f130cd50ac..343942deeec1 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c | |||
@@ -200,10 +200,8 @@ struct file *eventfd_fget(int fd) | |||
200 | 200 | ||
201 | asmlinkage long sys_eventfd(unsigned int count) | 201 | asmlinkage long sys_eventfd(unsigned int count) |
202 | { | 202 | { |
203 | int error, fd; | 203 | int fd; |
204 | struct eventfd_ctx *ctx; | 204 | struct eventfd_ctx *ctx; |
205 | struct file *file; | ||
206 | struct inode *inode; | ||
207 | 205 | ||
208 | ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); | 206 | ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); |
209 | if (!ctx) | 207 | if (!ctx) |
@@ -216,12 +214,9 @@ asmlinkage long sys_eventfd(unsigned int count) | |||
216 | * When we call this, the initialization must be complete, since | 214 | * When we call this, the initialization must be complete, since |
217 | * anon_inode_getfd() will install the fd. | 215 | * anon_inode_getfd() will install the fd. |
218 | */ | 216 | */ |
219 | error = anon_inode_getfd(&fd, &inode, &file, "[eventfd]", | 217 | fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx); |
220 | &eventfd_fops, ctx); | 218 | if (fd < 0) |
221 | if (!error) | 219 | kfree(ctx); |
222 | return fd; | 220 | return fd; |
223 | |||
224 | kfree(ctx); | ||
225 | return error; | ||
226 | } | 221 | } |
227 | 222 | ||