[PATCH 03/10] fs,kernel: Export d_absolute_path()/find_task_by_pid_ns()/find_task_by_vpid()

Serge E. Hallyn serge at hallyn.com
Sat Nov 5 23:51:11 UTC 2022


On Thu, Nov 03, 2022 at 02:10:18AM +0900, Tetsuo Handa wrote:
> CaitSith module which can be loaded using /sbin/insmod needs to be able to
> access these functions. TOMOYO module will also access these functions when
> CONFIG_SECURITY_TOMOYO=m becomes possible.
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel at I-love.SAKURA.ne.jp>
> ---
>  fs/d_path.c  | 1 +
>  kernel/pid.c | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/fs/d_path.c b/fs/d_path.c
> index 56a6ee4c6331..417e74414f19 100644
> --- a/fs/d_path.c
> +++ b/fs/d_path.c
> @@ -234,6 +234,7 @@ char *d_absolute_path(const struct path *path,
>  		return ERR_PTR(-EINVAL);
>  	return extract_string(&b);
>  }
> +EXPORT_SYMBOL_GPL(d_absolute_path);
>  
>  static void get_fs_root_rcu(struct fs_struct *fs, struct path *root)
>  {
> diff --git a/kernel/pid.c b/kernel/pid.c
> index 3fbc5e46b721..9e5224d8769c 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -416,11 +416,13 @@ struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
>  			 "find_task_by_pid_ns() needs rcu_read_lock() protection");
>  	return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
>  }
> +EXPORT_SYMBOL_GPL(find_task_by_pid_ns);
>  
>  struct task_struct *find_task_by_vpid(pid_t vnr)
>  {
>  	return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
>  }
> +EXPORT_SYMBOL_GPL(find_task_by_vpid);

It would be neat if you could avoid the need for these by instead using
pidfds.

>  struct task_struct *find_get_task_by_vpid(pid_t nr)
>  {
> -- 
> 2.18.4



More information about the Linux-security-module-archive mailing list