summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-03-07 17:45:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-07 17:45:22 -0500
commit8a9172356f747dc3734cc8043a44bbe158f44749 (patch)
treec4da6a57187fdbbd92b094bb4c5ad9330c36a07b
parent609b07b72d3caaa8eed3a238886467946b78fa5e (diff)
parentfa3aa7a54fe6d3abf128f13cd4bbd40eaa48fed2 (diff)
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Ingo Molnar: "This includes a fix for lockups caused by incorrect nsecs related cleanup, and a capabilities check fix for timerfd" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: jiffies: Revert bogus conversion of NSEC_PER_SEC to TICK_NSEC timerfd: Only check CAP_WAKE_ALARM when it is needed
-rw-r--r--fs/timerfd.c8
-rw-r--r--kernel/time/jiffies.c2
2 files changed, 5 insertions, 5 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 384fa759a563..c543cdb5f8ed 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -400,9 +400,9 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
400 clockid != CLOCK_BOOTTIME_ALARM)) 400 clockid != CLOCK_BOOTTIME_ALARM))
401 return -EINVAL; 401 return -EINVAL;
402 402
403 if (!capable(CAP_WAKE_ALARM) && 403 if ((clockid == CLOCK_REALTIME_ALARM ||
404 (clockid == CLOCK_REALTIME_ALARM || 404 clockid == CLOCK_BOOTTIME_ALARM) &&
405 clockid == CLOCK_BOOTTIME_ALARM)) 405 !capable(CAP_WAKE_ALARM))
406 return -EPERM; 406 return -EPERM;
407 407
408 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 408 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -449,7 +449,7 @@ static int do_timerfd_settime(int ufd, int flags,
449 return ret; 449 return ret;
450 ctx = f.file->private_data; 450 ctx = f.file->private_data;
451 451
452 if (!capable(CAP_WAKE_ALARM) && isalarm(ctx)) { 452 if (isalarm(ctx) && !capable(CAP_WAKE_ALARM)) {
453 fdput(f); 453 fdput(f);
454 return -EPERM; 454 return -EPERM;
455 } 455 }
diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c
index 7906b3f0c41a..497719127bf9 100644
--- a/kernel/time/jiffies.c
+++ b/kernel/time/jiffies.c
@@ -125,7 +125,7 @@ int register_refined_jiffies(long cycles_per_second)
125 shift_hz += cycles_per_tick/2; 125 shift_hz += cycles_per_tick/2;
126 do_div(shift_hz, cycles_per_tick); 126 do_div(shift_hz, cycles_per_tick);
127 /* Calculate nsec_per_tick using shift_hz */ 127 /* Calculate nsec_per_tick using shift_hz */
128 nsec_per_tick = (u64)TICK_NSEC << 8; 128 nsec_per_tick = (u64)NSEC_PER_SEC << 8;
129 nsec_per_tick += (u32)shift_hz/2; 129 nsec_per_tick += (u32)shift_hz/2;
130 do_div(nsec_per_tick, (u32)shift_hz); 130 do_div(nsec_per_tick, (u32)shift_hz);
131 131