[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxjD6Xsi-RV90xj-M9RbncTB5vPu2r_HLF1Es5hYixonLg@mail.gmail.com>
Date: Tue, 12 Nov 2024 16:59:11 +0100
From: Amir Goldstein <amir73il@...il.com>
To: Erin Shepherd <erin.shepherd@....eu>
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
christian@...uner.io, paul@...l-moore.com, bluca@...ian.org
Subject: Re: [PATCH 3/4] pid: introduce find_get_pid_ns
On Fri, Nov 1, 2024 at 2:56 PM Erin Shepherd <erin.shepherd@....eu> wrote:
>
> In some situations it is useful to be able to atomically get a PID
> from a specific PID namespace.
>
> Signed-off-by: Erin Shepherd <erin.shepherd@....eu>
Reviewed-by: Amir Goldstein <amir73il@...il.com>
> ---
> include/linux/pid.h | 1 +
> kernel/pid.c | 10 ++++++++--
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/pid.h b/include/linux/pid.h
> index a3aad9b4074c..965f8b3ff9a8 100644
> --- a/include/linux/pid.h
> +++ b/include/linux/pid.h
> @@ -124,6 +124,7 @@ extern struct pid *find_vpid(int nr);
> /*
> * Lookup a PID in the hash table, and return with it's count elevated.
> */
> +extern struct pid *find_get_pid_ns(int nr, struct pid_namespace *ns);
> extern struct pid *find_get_pid(int nr);
> extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
>
> diff --git a/kernel/pid.c b/kernel/pid.c
> index 2715afb77eab..2967f8a98330 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -470,16 +470,22 @@ struct task_struct *get_pid_task(struct pid *pid, enum pid_type type)
> }
> EXPORT_SYMBOL_GPL(get_pid_task);
>
> -struct pid *find_get_pid(pid_t nr)
> +struct pid *find_get_pid_ns(pid_t nr, struct pid_namespace *ns)
> {
> struct pid *pid;
>
> rcu_read_lock();
> - pid = get_pid(find_vpid(nr));
> + pid = get_pid(find_pid_ns(nr, ns));
> rcu_read_unlock();
>
> return pid;
> }
> +EXPORT_SYMBOL_GPL(find_get_pid_ns);
> +
> +struct pid *find_get_pid(pid_t nr)
> +{
> + return find_get_pid_ns(nr, task_active_pid_ns(current));
> +}
> EXPORT_SYMBOL_GPL(find_get_pid);
>
> pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
> --
> 2.46.1
>
>
Powered by blists - more mailing lists