Skip to content

Commit

Permalink
ntp: fix non privileged system time shifting
Browse files Browse the repository at this point in the history
The ADJ_SETOFFSET bit added in commit 094aa18 ("ntp: Add ADJ_SETOFFSET
mode bit") also introduced a way for any user to change the system time.
Sneaky or buggy calls to adjtimex() could set

    ADJ_OFFSET_SS_READ | ADJ_SETOFFSET

which would result in a successful call to timekeeping_inject_offset().
This patch fixes the issue by adding the capability check.

Signed-off-by: Richard Cochran <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
richardcochran authored and torvalds committed Apr 4, 2011
1 parent b3b896c commit 4352d9d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/time/ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ int do_adjtimex(struct timex *txc)
struct timespec delta;
delta.tv_sec = txc->time.tv_sec;
delta.tv_nsec = txc->time.tv_usec;
if (!capable(CAP_SYS_TIME))
return -EPERM;
if (!(txc->modes & ADJ_NANO))
delta.tv_nsec *= 1000;
result = timekeeping_inject_offset(&delta);
Expand Down

0 comments on commit 4352d9d

Please sign in to comment.