Skip to content

Commit 5fec25f

Browse files
committed
umh: Capture the pid in umh_pipe_setup
The pid in struct subprocess_info is only used by umh_clean_and_save_pid to write the pid into umh_info. Instead always capture the pid on struct umh_info in umh_pipe_setup, removing code that is specific to user mode drivers from the common user path of user mode helpers. 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 b3a9e3b commit 5fec25f

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

include/linux/umh.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ struct subprocess_info {
2525
struct file *file;
2626
int wait;
2727
int retval;
28-
pid_t pid;
2928
int (*init)(struct subprocess_info *info, struct cred *new);
3029
void (*cleanup)(struct subprocess_info *info);
3130
void *data;

kernel/umh.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ static int call_usermodehelper_exec_async(void *data)
102102

103103
commit_creds(new);
104104

105-
sub_info->pid = task_pid_nr(current);
106105
if (sub_info->file) {
107106
retval = do_execve_file(sub_info->file,
108107
sub_info->argv, sub_info->envp);
@@ -468,6 +467,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
468467

469468
umh_info->pipe_to_umh = to_umh[1];
470469
umh_info->pipe_from_umh = from_umh[0];
470+
umh_info->pid = task_pid_nr(current);
471471
return 0;
472472
}
473473

@@ -476,13 +476,12 @@ static void umh_clean_and_save_pid(struct subprocess_info *info)
476476
struct umh_info *umh_info = info->data;
477477

478478
/* cleanup if umh_pipe_setup() was successful but exec failed */
479-
if (info->pid && info->retval) {
479+
if (info->retval) {
480480
fput(umh_info->pipe_to_umh);
481481
fput(umh_info->pipe_from_umh);
482482
}
483483

484484
argv_free(info->argv);
485-
umh_info->pid = info->pid;
486485
}
487486

488487
/**

0 commit comments

Comments
 (0)