umd: Track user space drivers with struct pid
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 25 Jun 2020 21:48:26 +0000 (16:48 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Sat, 4 Jul 2020 14:35:56 +0000 (09:35 -0500)
commit1c340ead18ee4b4a84357abdef6d4f39ee08328b
tree412b58dd03cf04a9fd8cc26caae482628a0fbd71
parent0fe3c63148ef5df1b3cb067e4b4d45d45d0c0fdc
umd: Track user space drivers with struct pid

Use struct pid instead of user space pid values that are prone to wrap
araound.

In addition track the entire thread group instead of just the first
thread that is started by exec.  There are no multi-threaded user mode
drivers today but there is nothing preclucing user drivers from being
multi-threaded, so it is just a good idea to track the entire process.

Take a reference count on the tgid's in question to make it possible
to remove exit_umh in a future change.

As a struct pid is available directly use kill_pid_info.

The prior process signalling code was iffy in using a userspace pid
known to be in the initial pid namespace and then looking up it's task
in whatever the current pid namespace is.  It worked only because
kernel threads always run in the initial pid namespace.

As the tgid is now refcounted verify the tgid is NULL at the start of
fork_usermode_driver to avoid the possibility of silent pid leaks.

v1: https://lkml.kernel.org/r/87mu4qdlv2.fsf_-_@x220.int.ebiederm.org
v2: https://lkml.kernel.org/r/a70l4oy8.fsf_-_@x220.int.ebiederm.org
Link: https://lkml.kernel.org/r/20200702164140.4468-12-ebiederm@xmission.com
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
include/linux/usermode_driver.h
kernel/exit.c
kernel/usermode_driver.c
net/bpfilter/bpfilter_kern.c
net/ipv4/bpfilter/sockopt.c