diff options
| author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-07-18 18:00:58 -0400 |
|---|---|---|
| committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-07-18 18:00:58 -0400 |
| commit | 11388c87d2abca1f01975ced28ce9eacea239104 (patch) | |
| tree | 60e338e5ab817de96a461b08892e0663a316d67c /kernel/power | |
| parent | 823d93640927d739f7c918b73fe5ec494fb27e17 (diff) | |
PM / Sleep: Require CAP_BLOCK_SUSPEND to use wake_lock/wake_unlock
Require processes wanting to use the wake_lock/wake_unlock sysfs
files to have the CAP_BLOCK_SUSPEND capability, which also is
required for the eventpoll EPOLLWAKEUP flag to be effective, so that
all interfaces related to blocking autosleep depend on the same
capability.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: stable@vger.kernel.org
Acked-by: Michael Kerrisk <mtk.man-pages@gmail.com>
Diffstat (limited to 'kernel/power')
| -rw-r--r-- | kernel/power/wakelock.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c index c8fba3380076..8f50de394d22 100644 --- a/kernel/power/wakelock.c +++ b/kernel/power/wakelock.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | * manipulate wakelocks on Android. | 9 | * manipulate wakelocks on Android. |
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/capability.h> | ||
| 12 | #include <linux/ctype.h> | 13 | #include <linux/ctype.h> |
| 13 | #include <linux/device.h> | 14 | #include <linux/device.h> |
| 14 | #include <linux/err.h> | 15 | #include <linux/err.h> |
| @@ -188,6 +189,9 @@ int pm_wake_lock(const char *buf) | |||
| 188 | size_t len; | 189 | size_t len; |
| 189 | int ret = 0; | 190 | int ret = 0; |
| 190 | 191 | ||
| 192 | if (!capable(CAP_BLOCK_SUSPEND)) | ||
| 193 | return -EPERM; | ||
| 194 | |||
| 191 | while (*str && !isspace(*str)) | 195 | while (*str && !isspace(*str)) |
| 192 | str++; | 196 | str++; |
| 193 | 197 | ||
| @@ -231,6 +235,9 @@ int pm_wake_unlock(const char *buf) | |||
| 231 | size_t len; | 235 | size_t len; |
| 232 | int ret = 0; | 236 | int ret = 0; |
| 233 | 237 | ||
| 238 | if (!capable(CAP_BLOCK_SUSPEND)) | ||
| 239 | return -EPERM; | ||
| 240 | |||
| 234 | len = strlen(buf); | 241 | len = strlen(buf); |
| 235 | if (!len) | 242 | if (!len) |
| 236 | return -EINVAL; | 243 | return -EINVAL; |
