aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-03-23 18:02:48 -0400
committerLuis Henriques <luis.henriques@canonical.com>2012-04-05 11:17:14 -0400
commit322f5cfdfdcf001f8e9f53a6342ead60e9a6d077 (patch)
tree7da07e8d7244d4f72f9d7f896477ace06b121eb7
parentde7db9c247875ac10d4d27da70c668109e0108cf (diff)
usermodehelper: kill umh_wait, renumber UMH_* constants
BugLink: http://bugs.launchpad.net/bugs/963685 No functional changes. It is not sane to use UMH_KILLABLE with enum umh_wait, but obviously we do not want another argument in call_usermodehelper_* helpers. Kill this enum, use the plain int. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Tejun Heo <tj@kernel.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit 9d944ef32e83405a07376f112e9f02161d3e9731) Signed-off-by: Tim Gardner <tim.gardner@canonical.com> Acked-by: Stefan Bader <stefan.bader@canonical.com> Acked-by: Andy Whitcroft <andy.whitcroft@canonical.com>
-rw-r--r--include/linux/kmod.h18
-rw-r--r--kernel/kmod.c8
-rw-r--r--security/keys/request_key.c2
3 files changed, 10 insertions, 18 deletions
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 846f5695230..0f2c5a6b054 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -48,12 +48,9 @@ static inline int request_module_nowait(const char *name, ...) { return -ENOSYS;
48struct cred; 48struct cred;
49struct file; 49struct file;
50 50
51enum umh_wait { 51#define UMH_NO_WAIT 0 /* don't wait at all */
52 UMH_NO_WAIT = -1, /* don't wait at all */ 52#define UMH_WAIT_EXEC 1 /* wait for the exec, but not the process */
53 UMH_WAIT_EXEC = 0, /* wait for the exec, but not the process */ 53#define UMH_WAIT_PROC 2 /* wait for the process to complete */
54 UMH_WAIT_PROC = 1, /* wait for the process to complete */
55};
56
57#define UMH_KILLABLE 4 /* wait for EXEC/PROC killable */ 54#define UMH_KILLABLE 4 /* wait for EXEC/PROC killable */
58 55
59struct subprocess_info { 56struct subprocess_info {
@@ -62,7 +59,7 @@ struct subprocess_info {
62 char *path; 59 char *path;
63 char **argv; 60 char **argv;
64 char **envp; 61 char **envp;
65 enum umh_wait wait; 62 int wait;
66 int retval; 63 int retval;
67 int (*init)(struct subprocess_info *info, struct cred *new); 64 int (*init)(struct subprocess_info *info, struct cred *new);
68 void (*cleanup)(struct subprocess_info *info); 65 void (*cleanup)(struct subprocess_info *info);
@@ -80,7 +77,7 @@ void call_usermodehelper_setfns(struct subprocess_info *info,
80 void *data); 77 void *data);
81 78
82/* Actually execute the sub-process */ 79/* Actually execute the sub-process */
83int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait); 80int call_usermodehelper_exec(struct subprocess_info *info, int wait);
84 81
85/* Free the subprocess_info. This is only needed if you're not going 82/* Free the subprocess_info. This is only needed if you're not going
86 to call call_usermodehelper_exec */ 83 to call call_usermodehelper_exec */
@@ -89,8 +86,7 @@ void call_usermodehelper_freeinfo(struct subprocess_info *info);
89extern void populate_rootfs_wait(void); 86extern void populate_rootfs_wait(void);
90 87
91static inline int 88static inline int
92call_usermodehelper_fns(char *path, char **argv, char **envp, 89call_usermodehelper_fns(char *path, char **argv, char **envp, int wait,
93 enum umh_wait wait,
94 int (*init)(struct subprocess_info *info, struct cred *new), 90 int (*init)(struct subprocess_info *info, struct cred *new),
95 void (*cleanup)(struct subprocess_info *), void *data) 91 void (*cleanup)(struct subprocess_info *), void *data)
96{ 92{
@@ -110,7 +106,7 @@ call_usermodehelper_fns(char *path, char **argv, char **envp,
110} 106}
111 107
112static inline int 108static inline int
113call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) 109call_usermodehelper(char *path, char **argv, char **envp, int wait)
114{ 110{
115 return call_usermodehelper_fns(path, argv, envp, wait, 111 return call_usermodehelper_fns(path, argv, envp, wait,
116 NULL, NULL, NULL); 112 NULL, NULL, NULL);
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 4f895556d7b..8a65e7886f4 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -255,12 +255,9 @@ static void __call_usermodehelper(struct work_struct *work)
255{ 255{
256 struct subprocess_info *sub_info = 256 struct subprocess_info *sub_info =
257 container_of(work, struct subprocess_info, work); 257 container_of(work, struct subprocess_info, work);
258 enum umh_wait wait = sub_info->wait; 258 int wait = sub_info->wait & ~UMH_KILLABLE;
259 pid_t pid; 259 pid_t pid;
260 260
261 if (wait != UMH_NO_WAIT)
262 wait &= ~UMH_KILLABLE;
263
264 /* CLONE_VFORK: wait until the usermode helper has execve'd 261 /* CLONE_VFORK: wait until the usermode helper has execve'd
265 * successfully We need the data structures to stay around 262 * successfully We need the data structures to stay around
266 * until that is done. */ 263 * until that is done. */
@@ -430,8 +427,7 @@ EXPORT_SYMBOL(call_usermodehelper_setfns);
430 * asynchronously if wait is not set, and runs as a child of keventd. 427 * asynchronously if wait is not set, and runs as a child of keventd.
431 * (ie. it runs with full root capabilities). 428 * (ie. it runs with full root capabilities).
432 */ 429 */
433int call_usermodehelper_exec(struct subprocess_info *sub_info, 430int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
434 enum umh_wait wait)
435{ 431{
436 DECLARE_COMPLETION_ONSTACK(done); 432 DECLARE_COMPLETION_ONSTACK(done);
437 int retval = 0; 433 int retval = 0;
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 82465328c39..cc3790315d2 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -91,7 +91,7 @@ static void umh_keys_cleanup(struct subprocess_info *info)
91 * Call a usermode helper with a specific session keyring. 91 * Call a usermode helper with a specific session keyring.
92 */ 92 */
93static int call_usermodehelper_keys(char *path, char **argv, char **envp, 93static int call_usermodehelper_keys(char *path, char **argv, char **envp,
94 struct key *session_keyring, enum umh_wait wait) 94 struct key *session_keyring, int wait)
95{ 95{
96 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; 96 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
97 struct subprocess_info *info = 97 struct subprocess_info *info =