Skip to content
Snippets Groups Projects
Commit d5128962 authored by Raphael S. Carvalho's avatar Raphael S. Carvalho Committed by Pekka Enberg
Browse files

timerfd: Add nsec validity check to timerfd_settime


According to the manual page, the nsec field from both it_value
and it_interval must be checked, if wrong, return EINVAL.

Reviewed-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarRaphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 6bcc0740
No related branches found
No related tags found
No related merge requests found
......@@ -253,6 +253,11 @@ int timerfd_create(int clockid, int flags) {
static constexpr s64 second = 1000000000;
static bool check_nsec_validity(long nsec)
{
return (nsec >= 0 && nsec < second);
}
int timerfd_settime(int fd, int flags, const itimerspec *newval,
itimerspec *oldval)
{
......@@ -266,6 +271,11 @@ int timerfd_settime(int fd, int flags, const itimerspec *newval,
errno = EINVAL;
return -1;
}
if (!check_nsec_validity(newval->it_value.tv_nsec) ||
!check_nsec_validity(newval->it_interval.tv_nsec)) {
errno = EINVAL;
return -1;
}
s64 expiration, interval;
auto now = tf->time_now();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment