Skip to content

Commit 21d5982

Browse files
committed
umh: Remove call_usermodehelper_setup_file.
The only caller of call_usermodehelper_setup_file is fork_usermode_blob. In fork_usermode_blob replace call_usermodehelper_setup_file with call_usermodehelper_setup and delete fork_usermodehelper_setup_file. For this to work the argv_free is moved from umh_clean_and_save_pid to fork_usermode_blob. v1: https://lkml.kernel.org/r/[email protected] v2: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Reviewed-by: Greg Kroah-Hartman <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Tested-by: Alexei Starovoitov <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 3a17104 commit 21d5982

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

include/linux/umh.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ call_usermodehelper_setup(const char *path, char **argv, char **envp,
3939
int (*init)(struct subprocess_info *info, struct cred *new),
4040
void (*cleanup)(struct subprocess_info *), void *data);
4141

42-
struct subprocess_info *call_usermodehelper_setup_file(struct file *file,
43-
int (*init)(struct subprocess_info *info, struct cred *new),
44-
void (*cleanup)(struct subprocess_info *), void *data);
4542
struct umh_info {
4643
const char *cmdline;
4744
struct file *pipe_to_umh;

kernel/umh.c

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -402,33 +402,6 @@ struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
402402
}
403403
EXPORT_SYMBOL(call_usermodehelper_setup);
404404

405-
struct subprocess_info *call_usermodehelper_setup_file(struct file *file,
406-
int (*init)(struct subprocess_info *info, struct cred *new),
407-
void (*cleanup)(struct subprocess_info *info), void *data)
408-
{
409-
struct subprocess_info *sub_info;
410-
struct umh_info *info = data;
411-
const char *cmdline = (info->cmdline) ? info->cmdline : "usermodehelper";
412-
413-
sub_info = kzalloc(sizeof(struct subprocess_info), GFP_KERNEL);
414-
if (!sub_info)
415-
return NULL;
416-
417-
sub_info->argv = argv_split(GFP_KERNEL, cmdline, NULL);
418-
if (!sub_info->argv) {
419-
kfree(sub_info);
420-
return NULL;
421-
}
422-
423-
INIT_WORK(&sub_info->work, call_usermodehelper_exec_work);
424-
sub_info->path = "none";
425-
sub_info->file = file;
426-
sub_info->init = init;
427-
sub_info->cleanup = cleanup;
428-
sub_info->data = data;
429-
return sub_info;
430-
}
431-
432405
static int umd_setup(struct subprocess_info *info, struct cred *new)
433406
{
434407
struct umh_info *umh_info = info->data;
@@ -479,8 +452,6 @@ static void umd_cleanup(struct subprocess_info *info)
479452
fput(umh_info->pipe_to_umh);
480453
fput(umh_info->pipe_from_umh);
481454
}
482-
483-
argv_free(info->argv);
484455
}
485456

486457
/**
@@ -501,7 +472,9 @@ static void umd_cleanup(struct subprocess_info *info)
501472
*/
502473
int fork_usermode_blob(void *data, size_t len, struct umh_info *info)
503474
{
475+
const char *cmdline = (info->cmdline) ? info->cmdline : "usermodehelper";
504476
struct subprocess_info *sub_info;
477+
char **argv = NULL;
505478
struct file *file;
506479
ssize_t written;
507480
loff_t pos = 0;
@@ -520,18 +493,25 @@ int fork_usermode_blob(void *data, size_t len, struct umh_info *info)
520493
}
521494

522495
err = -ENOMEM;
523-
sub_info = call_usermodehelper_setup_file(file, umd_setup, umd_cleanup,
524-
info);
496+
argv = argv_split(GFP_KERNEL, cmdline, NULL);
497+
if (!argv)
498+
goto out;
499+
500+
sub_info = call_usermodehelper_setup("none", argv, NULL, GFP_KERNEL,
501+
umd_setup, umd_cleanup, info);
525502
if (!sub_info)
526503
goto out;
527504

505+
sub_info->file = file;
528506
err = call_usermodehelper_exec(sub_info, UMH_WAIT_EXEC);
529507
if (!err) {
530508
mutex_lock(&umh_list_lock);
531509
list_add(&info->list, &umh_list);
532510
mutex_unlock(&umh_list_lock);
533511
}
534512
out:
513+
if (argv)
514+
argv_free(argv);
535515
fput(file);
536516
return err;
537517
}

0 commit comments

Comments
 (0)