diff options
Diffstat (limited to 'kernel/kmod.c')
| -rw-r--r-- | kernel/kmod.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c index 20a997c73c3d..842f8015d7fd 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | */ | 20 | */ |
| 21 | #define __KERNEL_SYSCALLS__ | 21 | #define __KERNEL_SYSCALLS__ |
| 22 | 22 | ||
| 23 | #include <linux/config.h> | ||
| 24 | #include <linux/module.h> | 23 | #include <linux/module.h> |
| 25 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
| 26 | #include <linux/syscalls.h> | 25 | #include <linux/syscalls.h> |
| @@ -177,6 +176,8 @@ static int wait_for_helper(void *data) | |||
| 177 | if (pid < 0) { | 176 | if (pid < 0) { |
| 178 | sub_info->retval = pid; | 177 | sub_info->retval = pid; |
| 179 | } else { | 178 | } else { |
| 179 | int ret; | ||
| 180 | |||
| 180 | /* | 181 | /* |
| 181 | * Normally it is bogus to call wait4() from in-kernel because | 182 | * Normally it is bogus to call wait4() from in-kernel because |
| 182 | * wait4() wants to write the exit code to a userspace address. | 183 | * wait4() wants to write the exit code to a userspace address. |
| @@ -186,7 +187,15 @@ static int wait_for_helper(void *data) | |||
| 186 | * | 187 | * |
| 187 | * Thus the __user pointer cast is valid here. | 188 | * Thus the __user pointer cast is valid here. |
| 188 | */ | 189 | */ |
| 189 | sys_wait4(pid, (int __user *) &sub_info->retval, 0, NULL); | 190 | sys_wait4(pid, (int __user *)&ret, 0, NULL); |
| 191 | |||
| 192 | /* | ||
| 193 | * If ret is 0, either ____call_usermodehelper failed and the | ||
| 194 | * real error code is already in sub_info->retval or | ||
| 195 | * sub_info->retval is 0 anyway, so don't mess with it then. | ||
| 196 | */ | ||
| 197 | if (ret) | ||
| 198 | sub_info->retval = ret; | ||
| 190 | } | 199 | } |
| 191 | 200 | ||
| 192 | complete(sub_info->complete); | 201 | complete(sub_info->complete); |
| @@ -198,11 +207,12 @@ static void __call_usermodehelper(void *data) | |||
| 198 | { | 207 | { |
| 199 | struct subprocess_info *sub_info = data; | 208 | struct subprocess_info *sub_info = data; |
| 200 | pid_t pid; | 209 | pid_t pid; |
| 210 | int wait = sub_info->wait; | ||
| 201 | 211 | ||
| 202 | /* CLONE_VFORK: wait until the usermode helper has execve'd | 212 | /* CLONE_VFORK: wait until the usermode helper has execve'd |
| 203 | * successfully We need the data structures to stay around | 213 | * successfully We need the data structures to stay around |
| 204 | * until that is done. */ | 214 | * until that is done. */ |
| 205 | if (sub_info->wait) | 215 | if (wait) |
| 206 | pid = kernel_thread(wait_for_helper, sub_info, | 216 | pid = kernel_thread(wait_for_helper, sub_info, |
| 207 | CLONE_FS | CLONE_FILES | SIGCHLD); | 217 | CLONE_FS | CLONE_FILES | SIGCHLD); |
| 208 | else | 218 | else |
| @@ -212,7 +222,7 @@ static void __call_usermodehelper(void *data) | |||
| 212 | if (pid < 0) { | 222 | if (pid < 0) { |
| 213 | sub_info->retval = pid; | 223 | sub_info->retval = pid; |
| 214 | complete(sub_info->complete); | 224 | complete(sub_info->complete); |
| 215 | } else if (!sub_info->wait) | 225 | } else if (!wait) |
| 216 | complete(sub_info->complete); | 226 | complete(sub_info->complete); |
| 217 | } | 227 | } |
| 218 | 228 | ||
| @@ -234,7 +244,7 @@ static void __call_usermodehelper(void *data) | |||
| 234 | int call_usermodehelper_keys(char *path, char **argv, char **envp, | 244 | int call_usermodehelper_keys(char *path, char **argv, char **envp, |
| 235 | struct key *session_keyring, int wait) | 245 | struct key *session_keyring, int wait) |
| 236 | { | 246 | { |
| 237 | DECLARE_COMPLETION(done); | 247 | DECLARE_COMPLETION_ONSTACK(done); |
| 238 | struct subprocess_info sub_info = { | 248 | struct subprocess_info sub_info = { |
| 239 | .complete = &done, | 249 | .complete = &done, |
| 240 | .path = path, | 250 | .path = path, |
