Commit b044fa2a authored by Eric W. Biederman's avatar Eric W. Biederman

umh: Move setting PF_UMH into umh_pipe_setup

I am separating the code specific to user mode drivers from the code
for ordinary user space helpers.  Move setting of PF_UMH from
call_usermodehelper_exec_async which is core user mode helper code
into umh_pipe_setup which is user mode driver code.

The code is equally as easy to write in one location as the other and
the movement minimizes the impact of the user mode driver code on the
core of the user mode helper code.

Setting PF_UMH unconditionally is harmless as an action will only
happen if it is paired with an entry on umh_list.

v1: https://lkml.kernel.org/r/87bll6gf8t.fsf_-_@x220.int.ebiederm.org
v2: https://lkml.kernel.org/r/87zh8l63xs.fsf_-_@x220.int.ebiederm.org
Link: https://lkml.kernel.org/r/20200702164140.4468-2-ebiederm@xmission.comReviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Tested-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 5fec25f2
...@@ -102,12 +102,10 @@ static int call_usermodehelper_exec_async(void *data) ...@@ -102,12 +102,10 @@ static int call_usermodehelper_exec_async(void *data)
commit_creds(new); commit_creds(new);
if (sub_info->file) { if (sub_info->file)
retval = do_execve_file(sub_info->file, retval = do_execve_file(sub_info->file,
sub_info->argv, sub_info->envp); sub_info->argv, sub_info->envp);
if (!retval) else
current->flags |= PF_UMH;
} else
retval = do_execve(getname_kernel(sub_info->path), retval = do_execve(getname_kernel(sub_info->path),
(const char __user *const __user *)sub_info->argv, (const char __user *const __user *)sub_info->argv,
(const char __user *const __user *)sub_info->envp); (const char __user *const __user *)sub_info->envp);
...@@ -468,6 +466,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) ...@@ -468,6 +466,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
umh_info->pipe_to_umh = to_umh[1]; umh_info->pipe_to_umh = to_umh[1];
umh_info->pipe_from_umh = from_umh[0]; umh_info->pipe_from_umh = from_umh[0];
umh_info->pid = task_pid_nr(current); umh_info->pid = task_pid_nr(current);
current->flags |= PF_UMH;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment