Skip to contentSkip to conversation

ntp, security: fix non privileged system time shifting

PATCH New Richard Cochran 1 participant 1 message Apr 1, 2011 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntp, security: fix non privileged system time shifting

The ADJ_SETOFFSET bit added in commit 094aa188 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.

---
 kernel/time/ntp.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/time/ntp.c +2 -0
index 35e68e3..5e65fd5 100644
@@ -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);
Signature · 1 line
1.7.0.4