aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2008-07-25 04:45:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:28 -0400
commitac331d158e198d2a91a5b0a3ec4ca9991fdb57af (patch)
treeb0921e2bc8e59d5df2c554c41c3b9f04e05d6d7c /include/linux
parentf557d0996a6f9c06912528ea85e1dba0fb7d485f (diff)
call_usermodehelper(): increase reliability
Presently call_usermodehelper_setup() uses GFP_ATOMIC. but it can return NULL _very_ easily. GFP_ATOMIC is needed only when we can't sleep. and, GFP_KERNEL is robust and better. thus, I add gfp_mask argument to call_usermodehelper_setup(). So, its callers pass the gfp_t as below: call_usermodehelper() and call_usermodehelper_keys(): depend on 'wait' argument. call_usermodehelper_pipe(): always GFP_KERNEL because always run under process context. orderly_poweroff(): pass to GFP_ATOMIC because may run under interrupt context. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: "Paul Menage" <menage@google.com> Reviewed-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Jeremy Fitzhardinge <jeremy@xensource.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Andi Kleen <andi@firstfloor.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/kmod.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 0509c4ce485..a1a91577813 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/gfp.h>
22#include <linux/stddef.h> 23#include <linux/stddef.h>
23#include <linux/errno.h> 24#include <linux/errno.h>
24#include <linux/compiler.h> 25#include <linux/compiler.h>
@@ -41,8 +42,8 @@ struct file;
41struct subprocess_info; 42struct subprocess_info;
42 43
43/* Allocate a subprocess_info structure */ 44/* Allocate a subprocess_info structure */
44struct subprocess_info *call_usermodehelper_setup(char *path, 45struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
45 char **argv, char **envp); 46 char **envp, gfp_t gfp_mask);
46 47
47/* Set various pieces of state into the subprocess_info structure */ 48/* Set various pieces of state into the subprocess_info structure */
48void call_usermodehelper_setkeys(struct subprocess_info *info, 49void call_usermodehelper_setkeys(struct subprocess_info *info,
@@ -69,8 +70,9 @@ static inline int
69call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) 70call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait)
70{ 71{
71 struct subprocess_info *info; 72 struct subprocess_info *info;
73 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
72 74
73 info = call_usermodehelper_setup(path, argv, envp); 75 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
74 if (info == NULL) 76 if (info == NULL)
75 return -ENOMEM; 77 return -ENOMEM;
76 return call_usermodehelper_exec(info, wait); 78 return call_usermodehelper_exec(info, wait);
@@ -81,8 +83,9 @@ call_usermodehelper_keys(char *path, char **argv, char **envp,
81 struct key *session_keyring, enum umh_wait wait) 83 struct key *session_keyring, enum umh_wait wait)
82{ 84{
83 struct subprocess_info *info; 85 struct subprocess_info *info;
86 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
84 87
85 info = call_usermodehelper_setup(path, argv, envp); 88 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
86 if (info == NULL) 89 if (info == NULL)
87 return -ENOMEM; 90 return -ENOMEM;
88 91