X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=kernel%2Fkernel%2Ftime%2Fntp.c;fp=kernel%2Fkernel%2Ftime%2Fntp.c;h=0f6868fd2de636a98963cc229701277f00fc7e49;hb=52f993b8e89487ec9ee15a7fb4979e0f09a45b27;hp=cd925efb239abf8a8b29ef6ca11a27460ad8c742;hpb=c189ccac5702322ed843fe17057035b7222a59b6;p=kvmfornfv.git diff --git a/kernel/kernel/time/ntp.c b/kernel/kernel/time/ntp.c index cd925efb2..0f6868fd2 100644 --- a/kernel/kernel/time/ntp.c +++ b/kernel/kernel/time/ntp.c @@ -717,8 +717,24 @@ int ntp_validate_timex(struct timex *txc) return -EINVAL; } - if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) - return -EPERM; + if (txc->modes & ADJ_SETOFFSET) { + /* In order to inject time, you gotta be super-user! */ + if (!capable(CAP_SYS_TIME)) + return -EPERM; + + if (txc->modes & ADJ_NANO) { + struct timespec ts; + + ts.tv_sec = txc->time.tv_sec; + ts.tv_nsec = txc->time.tv_usec; + if (!timespec_inject_offset_valid(&ts)) + return -EINVAL; + + } else { + if (!timeval_inject_offset_valid(&txc->time)) + return -EINVAL; + } + } /* * Check for potential multiplication overflows that can