rtc: allow validated RTC_PIE_ON for non-root
authorBryan Kadzban <[email protected]>
Tue, 16 Oct 2007 08:28:23 +0000 (01:28 -0700)
committerLinus Torvalds <[email protected]>
Tue, 16 Oct 2007 16:43:13 +0000 (09:43 -0700)
drivers/char/rtc.c allowed RTC_PIE_ON ioctls for non-root users, as long as
the current interval (set via RTC_IRQP_SET) is <= max_user_freq.  Allow
RTC_PIE_ON under the same conditions when /dev/rtc* is handled by the rtc
subsystem.

Signed-off-by: Bryan Kadzban <[email protected]>
Acked-by: Alessandro Zummo <[email protected]>
Cc: David Brownell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/rtc/rtc-dev.c

index 87d4add6b7f68346750350f63232de332b75bd80..814583bd2fe709c1da0710808ed6f4cffbe8b50f 100644 (file)
@@ -233,7 +233,8 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
                break;
 
        case RTC_PIE_ON:
-               if (!capable(CAP_SYS_RESOURCE))
+               if (rtc->irq_freq > rtc->max_user_freq &&
+                               !capable(CAP_SYS_RESOURCE))
                        return -EACCES;
                break;
        }