Commit 8cdd4936 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds

PM: disable usermode helper before hibernation and suspend

Use a hibernation and suspend notifier to disable the user mode helper before
a hibernation/suspend and enable it after the operation.

[akpm@linux-foundation.org: build fix]
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Acked-by: default avatarNigel Cunningham <nigel@nigel.suspend2.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b10d9117
...@@ -33,12 +33,22 @@ ...@@ -33,12 +33,22 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/resource.h> #include <linux/resource.h>
#include <linux/notifier.h>
#include <linux/suspend.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
extern int max_threads; extern int max_threads;
static struct workqueue_struct *khelper_wq; static struct workqueue_struct *khelper_wq;
/*
* If set, both call_usermodehelper_keys() and call_usermodehelper_pipe() exit
* immediately returning -EBUSY. Used for preventing user land processes from
* being created after the user land has been frozen during a system-wide
* hibernation or suspend operation.
*/
static int usermodehelper_disabled;
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
/* /*
...@@ -265,6 +275,24 @@ static void __call_usermodehelper(struct work_struct *work) ...@@ -265,6 +275,24 @@ static void __call_usermodehelper(struct work_struct *work)
} }
} }
static int usermodehelper_pm_callback(struct notifier_block *nfb,
unsigned long action,
void *ignored)
{
switch (action) {
case PM_HIBERNATION_PREPARE:
case PM_SUSPEND_PREPARE:
usermodehelper_disabled = 1;
return NOTIFY_OK;
case PM_POST_HIBERNATION:
case PM_POST_SUSPEND:
usermodehelper_disabled = 0;
return NOTIFY_OK;
}
return NOTIFY_DONE;
}
/** /**
* call_usermodehelper_setup - prepare to call a usermode helper * call_usermodehelper_setup - prepare to call a usermode helper
* @path - path to usermode executable * @path - path to usermode executable
...@@ -374,7 +402,7 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, ...@@ -374,7 +402,7 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info,
goto out; goto out;
} }
if (!khelper_wq) { if (!khelper_wq || usermodehelper_disabled) {
retval = -EBUSY; retval = -EBUSY;
goto out; goto out;
} }
...@@ -431,4 +459,5 @@ void __init usermodehelper_init(void) ...@@ -431,4 +459,5 @@ void __init usermodehelper_init(void)
{ {
khelper_wq = create_singlethread_workqueue("khelper"); khelper_wq = create_singlethread_workqueue("khelper");
BUG_ON(!khelper_wq); BUG_ON(!khelper_wq);
pm_notifier(usermodehelper_pm_callback, 0);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment