mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
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>
35 lines
781 B
C
35 lines
781 B
C
#ifndef __LINUX_USERMODE_DRIVER_H__
|
|
#define __LINUX_USERMODE_DRIVER_H__
|
|
|
|
#include <linux/umh.h>
|
|
#include <linux/path.h>
|
|
|
|
#ifdef CONFIG_BPFILTER
|
|
void __exit_umh(struct task_struct *tsk);
|
|
|
|
static inline void exit_umh(struct task_struct *tsk)
|
|
{
|
|
if (unlikely(tsk->flags & PF_UMH))
|
|
__exit_umh(tsk);
|
|
}
|
|
#else
|
|
static inline void exit_umh(struct task_struct *tsk)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
struct umd_info {
|
|
const char *driver_name;
|
|
struct file *pipe_to_umh;
|
|
struct file *pipe_from_umh;
|
|
struct list_head list;
|
|
void (*cleanup)(struct umd_info *info);
|
|
struct path wd;
|
|
struct pid *tgid;
|
|
};
|
|
int umd_load_blob(struct umd_info *info, const void *data, size_t len);
|
|
int umd_unload_blob(struct umd_info *info);
|
|
int fork_usermode_driver(struct umd_info *info);
|
|
|
|
#endif /* __LINUX_USERMODE_DRIVER_H__ */
|