diff options
author | Davide Libenzi <davidel@xmailserver.org> | 2007-07-26 13:41:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-26 14:35:17 -0400 |
commit | 098284020c47c1212d211e39ae2b41c21182e056 (patch) | |
tree | f82e03b01a567a536f2f7b5c59671de2cf1f7dc2 /fs | |
parent | a1cdd4a64f6ce15a1e81759ef99eed3a91f9acbe (diff) |
make timerfd return a u64 and fix the __put_user
Davi fixed a missing cast in the __put_user(), that was making timerfd
return a single byte instead of the full value.
Talking with Michael about the timerfd man page, we think it'd be better to
use a u64 for the returned value, to align it with the eventfd
implementation.
This is an ABI change. The timerfd code is new in 2.6.22 and if we merge this
into 2.6.23 then we should also merge it into 2.6.22.x. That will leave a few
early 2.6.22 kernels out in the wild which might misbehave when a future
timerfd-enabled glibc is run on them.
mtk says: The difference would be that read() will only return 4 bytes, while
the application will expect 8. If the application is checking the size of
returned value, as it should, then it will be able to detect the problem (it
could even be sophisticated enough to know that if this is a 4-byte return,
then it is running on an old 2.6.22 kernel). If the application is not
checking the return from read(), then its 8-byte buffer will not be filled --
the contents of the last 4 bytes will be undefined, so the u64 value as a
whole will be junk.
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: Davi Arnaut <davi@haxent.com.br>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/timerfd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c index af9eca5c0230..61983f3b107c 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c | |||
@@ -95,7 +95,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, | |||
95 | { | 95 | { |
96 | struct timerfd_ctx *ctx = file->private_data; | 96 | struct timerfd_ctx *ctx = file->private_data; |
97 | ssize_t res; | 97 | ssize_t res; |
98 | u32 ticks = 0; | 98 | u64 ticks = 0; |
99 | DECLARE_WAITQUEUE(wait, current); | 99 | DECLARE_WAITQUEUE(wait, current); |
100 | 100 | ||
101 | if (count < sizeof(ticks)) | 101 | if (count < sizeof(ticks)) |
@@ -130,7 +130,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, | |||
130 | * callback to avoid DoS attacks specifying a very | 130 | * callback to avoid DoS attacks specifying a very |
131 | * short timer period. | 131 | * short timer period. |
132 | */ | 132 | */ |
133 | ticks = (u32) | 133 | ticks = (u64) |
134 | hrtimer_forward(&ctx->tmr, | 134 | hrtimer_forward(&ctx->tmr, |
135 | hrtimer_cb_get_time(&ctx->tmr), | 135 | hrtimer_cb_get_time(&ctx->tmr), |
136 | ctx->tintv); | 136 | ctx->tintv); |
@@ -140,7 +140,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, | |||
140 | } | 140 | } |
141 | spin_unlock_irq(&ctx->wqh.lock); | 141 | spin_unlock_irq(&ctx->wqh.lock); |
142 | if (ticks) | 142 | if (ticks) |
143 | res = put_user(ticks, buf) ? -EFAULT: sizeof(ticks); | 143 | res = put_user(ticks, (u64 __user *) buf) ? -EFAULT: sizeof(ticks); |
144 | return res; | 144 | return res; |
145 | } | 145 | } |
146 | 146 | ||