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/timerfd.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/timerfd.c')
-rw-r--r-- | fs/timerfd.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c index 5400524e9cb1..d87d354ec424 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c | |||
@@ -181,10 +181,8 @@ static struct file *timerfd_fget(int fd) | |||
181 | 181 | ||
182 | asmlinkage long sys_timerfd_create(int clockid, int flags) | 182 | asmlinkage long sys_timerfd_create(int clockid, int flags) |
183 | { | 183 | { |
184 | int error, ufd; | 184 | int ufd; |
185 | struct timerfd_ctx *ctx; | 185 | struct timerfd_ctx *ctx; |
186 | struct file *file; | ||
187 | struct inode *inode; | ||
188 | 186 | ||
189 | if (flags) | 187 | if (flags) |
190 | return -EINVAL; | 188 | return -EINVAL; |
@@ -200,12 +198,9 @@ asmlinkage long sys_timerfd_create(int clockid, int flags) | |||
200 | ctx->clockid = clockid; | 198 | ctx->clockid = clockid; |
201 | hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); | 199 | hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); |
202 | 200 | ||
203 | error = anon_inode_getfd(&ufd, &inode, &file, "[timerfd]", | 201 | ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx); |
204 | &timerfd_fops, ctx); | 202 | if (ufd < 0) |
205 | if (error) { | ||
206 | kfree(ctx); | 203 | kfree(ctx); |
207 | return error; | ||
208 | } | ||
209 | 204 | ||
210 | return ufd; | 205 | return ufd; |
211 | } | 206 | } |