aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2011-04-04 11:31:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-04-04 11:31:23 -0400
commit4352d9d44b935e4d000be6ec89ddb55c2bf35f24 (patch)
tree26b9d37f5a41b4c01d800a444ad230eafb48e47a /kernel
parentb3b896c73b4b04b506816a09994192e3a54f0fef (diff)
ntp: fix non privileged system time shifting
The ADJ_SETOFFSET bit added in commit 094aa188 ("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 <richard.cochran@omicron.at> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/ntp.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 5f1bb8e2008f..f6117a4c7cb8 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -652,6 +652,8 @@ int do_adjtimex(struct timex *txc)
652 struct timespec delta; 652 struct timespec delta;
653 delta.tv_sec = txc->time.tv_sec; 653 delta.tv_sec = txc->time.tv_sec;
654 delta.tv_nsec = txc->time.tv_usec; 654 delta.tv_nsec = txc->time.tv_usec;
655 if (!capable(CAP_SYS_TIME))
656 return -EPERM;
655 if (!(txc->modes & ADJ_NANO)) 657 if (!(txc->modes & ADJ_NANO))
656 delta.tv_nsec *= 1000; 658 delta.tv_nsec *= 1000;
657 result = timekeeping_inject_offset(&delta); 659 result = timekeeping_inject_offset(&delta);