* [PATCH][RFC] Check poll_select_set_timeout return value in sys_poll
@ 2011-01-23 23:01 Jesper Juhl
2011-01-23 23:10 ` Jesper Juhl
0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2011-01-23 23:01 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-fsdevel, Alexander Viro
poll_select_set_timeout() may return -EINVAL if it's given invalid
arguments. In sys_poll() we don't check the return value. The way
poll_select_set_timeout() is called here currently I don't think can ever
actually fail, but it doesn't hurt to be defensive - code has a tendency
to change over time. This patch checks the return value and returns
-EINVAL just like we do elsewhere if it does fail.
What do you think? Is this just pointless overhead or actually worth it as
an "insurance policy"?
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
select.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/select.c b/fs/select.c
index e56560d..333d5aa 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -922,8 +922,9 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
if (timeout_msecs >= 0) {
to = &end_time;
- poll_select_set_timeout(to, timeout_msecs / MSEC_PER_SEC,
- NSEC_PER_MSEC * (timeout_msecs % MSEC_PER_SEC));
+ if (poll_select_set_timeout(to, timeout_msecs / MSEC_PER_SEC,
+ NSEC_PER_MSEC * (timeout_msecs % MSEC_PER_SEC)))
+ return -EINVAL;
}
ret = do_sys_poll(ufds, nfds, to);
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][RFC] Check poll_select_set_timeout return value in sys_poll
2011-01-23 23:01 [PATCH][RFC] Check poll_select_set_timeout return value in sys_poll Jesper Juhl
@ 2011-01-23 23:10 ` Jesper Juhl
0 siblings, 0 replies; 2+ messages in thread
From: Jesper Juhl @ 2011-01-23 23:10 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-fsdevel, Alexander Viro
On Mon, 24 Jan 2011, Jesper Juhl wrote:
> poll_select_set_timeout() may return -EINVAL if it's given invalid
> arguments. In sys_poll() we don't check the return value. The way
> poll_select_set_timeout() is called here currently I don't think can ever
> actually fail, but it doesn't hurt to be defensive - code has a tendency
> to change over time. This patch checks the return value and returns
> -EINVAL just like we do elsewhere if it does fail.
>
> What do you think? Is this just pointless overhead or actually worth it as
> an "insurance policy"?
>
I guess that if we do this we should at least mark this branch as
unlikely().
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
select.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/select.c b/fs/select.c
index e56560d..ebdca6e 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -922,8 +922,9 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
if (timeout_msecs >= 0) {
to = &end_time;
- poll_select_set_timeout(to, timeout_msecs / MSEC_PER_SEC,
- NSEC_PER_MSEC * (timeout_msecs % MSEC_PER_SEC));
+ if (unlikely(poll_select_set_timeout(to, timeout_msecs / MSEC_PER_SEC,
+ NSEC_PER_MSEC * (timeout_msecs % MSEC_PER_SEC))))
+ return -EINVAL;
}
ret = do_sys_poll(ufds, nfds, to);
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-23 23:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-23 23:01 [PATCH][RFC] Check poll_select_set_timeout return value in sys_poll Jesper Juhl
2011-01-23 23:10 ` Jesper Juhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).