Skip to content

Commit

Permalink
PM / Sleep: Require CAP_BLOCK_SUSPEND to use wake_lock/wake_unlock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafael J. Wysocki committed Jul 18, 2012
1 parent 823d936 commit 11388c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kernel/power/wakelock.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* manipulate wakelocks on Android.
*/

#include <linux/capability.h>
#include <linux/ctype.h>
#include <linux/device.h>
#include <linux/err.h>
Expand Down Expand Up @@ -188,6 +189,9 @@ int pm_wake_lock(const char *buf)
size_t len;
int ret = 0;

if (!capable(CAP_BLOCK_SUSPEND))
return -EPERM;

while (*str && !isspace(*str))
str++;

Expand Down Expand Up @@ -231,6 +235,9 @@ int pm_wake_unlock(const char *buf)
size_t len;
int ret = 0;

if (!capable(CAP_BLOCK_SUSPEND))
return -EPERM;

len = strlen(buf);
if (!len)
return -EINVAL;
Expand Down

0 comments on commit 11388c8

Please sign in to comment.