diff options
author | Neil Horman <nhorman@tuxdriver.com> | 2010-05-26 17:42:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:44 -0400 |
commit | 898b374af6f71041bd3bceebe257e564f3f1d458 (patch) | |
tree | b1be6fd3cca69becfc75787eab906338f363d3cd /kernel | |
parent | a06a4dc3a08201ff6a8a958f935b3cbf7744115f (diff) |
exec: replace call_usermodehelper_pipe with use of umh init function and resolve limit
The first patch in this series introduced an init function to the
call_usermodehelper api so that processes could be customized by caller.
This patch takes advantage of that fact, by customizing the helper in
do_coredump to create the pipe and set its core limit to one (for our
recusrsion check). This lets us clean up the previous uglyness in the
usermodehelper internals and factor call_usermodehelper out entirely.
While I'm at it, we can also modify the helper setup to look for a core
limit value of 1 rather than zero for our recursion check
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
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 'kernel')
-rw-r--r-- | kernel/kmod.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c index 531ef62cf536..d1544547fea6 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -147,23 +147,6 @@ static int ____call_usermodehelper(void *data) | |||
147 | commit_creds(sub_info->cred); | 147 | commit_creds(sub_info->cred); |
148 | sub_info->cred = NULL; | 148 | sub_info->cred = NULL; |
149 | 149 | ||
150 | /* Install input pipe when needed */ | ||
151 | if (sub_info->stdin) { | ||
152 | struct files_struct *f = current->files; | ||
153 | struct fdtable *fdt; | ||
154 | /* no races because files should be private here */ | ||
155 | sys_close(0); | ||
156 | fd_install(0, sub_info->stdin); | ||
157 | spin_lock(&f->file_lock); | ||
158 | fdt = files_fdtable(f); | ||
159 | FD_SET(0, fdt->open_fds); | ||
160 | FD_CLR(0, fdt->close_on_exec); | ||
161 | spin_unlock(&f->file_lock); | ||
162 | |||
163 | /* and disallow core files too */ | ||
164 | current->signal->rlim[RLIMIT_CORE] = (struct rlimit){0, 0}; | ||
165 | } | ||
166 | |||
167 | /* We can run anywhere, unlike our parent keventd(). */ | 150 | /* We can run anywhere, unlike our parent keventd(). */ |
168 | set_cpus_allowed_ptr(current, cpu_all_mask); | 151 | set_cpus_allowed_ptr(current, cpu_all_mask); |
169 | 152 | ||
@@ -429,35 +412,6 @@ void call_usermodehelper_setfns(struct subprocess_info *info, | |||
429 | EXPORT_SYMBOL(call_usermodehelper_setfns); | 412 | EXPORT_SYMBOL(call_usermodehelper_setfns); |
430 | 413 | ||
431 | /** | 414 | /** |
432 | * call_usermodehelper_stdinpipe - set up a pipe to be used for stdin | ||
433 | * @sub_info: a subprocess_info returned by call_usermodehelper_setup | ||
434 | * @filp: set to the write-end of a pipe | ||
435 | * | ||
436 | * This constructs a pipe, and sets the read end to be the stdin of the | ||
437 | * subprocess, and returns the write-end in *@filp. | ||
438 | */ | ||
439 | int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info, | ||
440 | struct file **filp) | ||
441 | { | ||
442 | struct file *f; | ||
443 | |||
444 | f = create_write_pipe(0); | ||
445 | if (IS_ERR(f)) | ||
446 | return PTR_ERR(f); | ||
447 | *filp = f; | ||
448 | |||
449 | f = create_read_pipe(f, 0); | ||
450 | if (IS_ERR(f)) { | ||
451 | free_write_pipe(*filp); | ||
452 | return PTR_ERR(f); | ||
453 | } | ||
454 | sub_info->stdin = f; | ||
455 | |||
456 | return 0; | ||
457 | } | ||
458 | EXPORT_SYMBOL(call_usermodehelper_stdinpipe); | ||
459 | |||
460 | /** | ||
461 | * call_usermodehelper_exec - start a usermode application | 415 | * call_usermodehelper_exec - start a usermode application |
462 | * @sub_info: information about the subprocessa | 416 | * @sub_info: information about the subprocessa |
463 | * @wait: wait for the application to finish and return status. | 417 | * @wait: wait for the application to finish and return status. |
@@ -504,42 +458,6 @@ unlock: | |||
504 | } | 458 | } |
505 | EXPORT_SYMBOL(call_usermodehelper_exec); | 459 | EXPORT_SYMBOL(call_usermodehelper_exec); |
506 | 460 | ||
507 | /** | ||
508 | * call_usermodehelper_pipe - call a usermode helper process with a pipe stdin | ||
509 | * @path: path to usermode executable | ||
510 | * @argv: arg vector for process | ||
511 | * @envp: environment for process | ||
512 | * @filp: set to the write-end of a pipe | ||
513 | * | ||
514 | * This is a simple wrapper which executes a usermode-helper function | ||
515 | * with a pipe as stdin. It is implemented entirely in terms of | ||
516 | * lower-level call_usermodehelper_* functions. | ||
517 | */ | ||
518 | int call_usermodehelper_pipe(char *path, char **argv, char **envp, | ||
519 | struct file **filp) | ||
520 | { | ||
521 | struct subprocess_info *sub_info; | ||
522 | int ret; | ||
523 | |||
524 | sub_info = call_usermodehelper_setup(path, argv, envp, | ||
525 | GFP_KERNEL); | ||
526 | if (sub_info == NULL) | ||
527 | return -ENOMEM; | ||
528 | |||
529 | ret = call_usermodehelper_stdinpipe(sub_info, filp); | ||
530 | if (ret < 0) { | ||
531 | call_usermodehelper_freeinfo(sub_info); | ||
532 | return ret; | ||
533 | } | ||
534 | |||
535 | ret = call_usermodehelper_exec(sub_info, UMH_WAIT_EXEC); | ||
536 | if (ret < 0) /* Failed to execute helper, close pipe */ | ||
537 | filp_close(*filp, NULL); | ||
538 | |||
539 | return ret; | ||
540 | } | ||
541 | EXPORT_SYMBOL(call_usermodehelper_pipe); | ||
542 | |||
543 | void __init usermodehelper_init(void) | 461 | void __init usermodehelper_init(void) |
544 | { | 462 | { |
545 | khelper_wq = create_singlethread_workqueue("khelper"); | 463 | khelper_wq = create_singlethread_workqueue("khelper"); |