Re: [PATCHv4 bpf-next 05/28] bpf: Add pid filter support for uprobe_multi link

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/21, Yafang Shao wrote:
>
> On Thu, Jul 20, 2023 at 7:36 PM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> >
> > Adding support to specify pid for uprobe_multi link and the uprobes
> > are created only for task with given pid value.
>
> Is it possible to use tgid as the filter?
> It would be helpful when we uprobe a library file but want to filter
> out a multi-threaded task only.

I leave this to you and Jiri, just some notes...

I think it is possible but needs some complications.

uprobe_prog_run() needs a trivial change,

	-	if (link->task && current != link->task)
	+	if (link->task && same_thread_group(current, link->task)

->signal is tied to task_struct so this should work even if link->task has
already exited.


bpf_uprobe_multi_link_attach() should probably use

	get_pid_task(find_vpid(pid), PIDTYPE_TGID);

to ensure that 'pid' is actually tgid.


But. uprobe_multi_link_filter() can return F if the group leader has already
exited, in this case uprobe->link->task->mm == NULL.

Perhaps we can simply ignore this case, a zombie group-leader is not that common.

Or we can add uprobe->link->mm = get_task_mm(uprobe->link->task->mm) for
uprobe_multi_link_filter().

Or. We can simply kill uprobe_multi_link_filter(). In this case uprobe_register()
can touch CLONE_VM'ed mm's we are not interested in, but everything should work
correctly.

Oleg.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux