Re: [PATCH 2/4] pid: Export find_task_by_vpid for use in external modules
From: Eric W. Biederman
Date: Tue May 08 2018 - 21:23:43 EST
Kim Phillips <kim.phillips@xxxxxxx> writes:
> This patch is in the context of allowing the Coresight h/w
> trace driver suite to be loaded as modules. Coresight uses
> find_task_by_vpid when running in direct capture mode (via sysfs)
> when getting/setting the context ID comparator to trigger on
> (/sys/bus/coresight/devices/<x>.etm/ctxid_pid).
Nacked-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
There is no way to implement a sysfs file that takes a pid correctly.
Don't do it.
Pids are tied to pid namespaces and sysfs deliberately does not do
anything remotely resembly a pid namespace.
Eric
> Cc: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
> Cc: Gargi Sharma <gs051095@xxxxxxxxx>
> Cc: Rik van Riel <riel@xxxxxxxxxx>
> Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
> Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
> Cc: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx>
> Cc: David Howells <dhowells@xxxxxxxxxx>
> Cc: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
> Signed-off-by: Kim Phillips <kim.phillips@xxxxxxx>
> ---
> Current CoreSight callsite:
>
> https://lxr.missinglinkelectronics.com/linux/include/linux/coresight.h#L285
>
> A quick look didn't find anything, but if Coresight needs to do
> something differently, please comment.
>
> kernel/pid.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/pid.c b/kernel/pid.c
> index 157fe4b19971..92b1b623f3e0 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -342,6 +342,7 @@ 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);
>
> struct task_struct *find_get_task_by_vpid(pid_t nr)
> {