Re: [PATCH] epoll: Add a flag, EPOLLWAKEUP, to prevent suspend whileepoll events are ready

From: Michael Kerrisk (man-pages)
Date: Wed Jul 18 2012 - 02:42:05 EST


On Tue, Jul 17, 2012 at 9:22 PM, Rafael J. Wysocki <rjw@xxxxxxx> wrote:

[...]

> I'm going to push your patch for v3.5,

Thanks.

> but then I'm considering the following
> one for v3.6. I wouldn't like to make more changes in v3.5-rc at this point,

Acked-by: Michael Kerrisk <mtk.man-pages@xxxxxxxxx>

Thanks,

Michael

> ---
> From: Rafael J. Wysocki <rjw@xxxxxxx>
> Subject: 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@xxxxxxx>
> ---
> kernel/power/wakelock.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> Index: linux/kernel/power/wakelock.c
> ===================================================================
> --- linux.orig/kernel/power/wakelock.c
> +++ linux/kernel/power/wakelock.c
> @@ -9,6 +9,7 @@
> * manipulate wakelocks on Android.
> */
>
> +#include <linux/capability.h>
> #include <linux/ctype.h>
> #include <linux/device.h>
> #include <linux/err.h>
> @@ -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++;
>
> @@ -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;



--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/