Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit uprobes in shared libraries to a single process when -p is given #2817

Closed
viktormalik opened this issue Nov 1, 2023 · 1 comment
Closed
Labels
enhancement New feature or request, changes on existing features

Comments

@viktormalik
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When attaching to uprobes in shared libraries, the -p option is ignored, i.e. library functions called from all processes are hit. Limiting to the calls from the given process would make more sense, e.g. the gethostlatency.bt tool (which attaches to several libc functions) could be used per-process:

# bpftrace gethostlatency.bt -p $(pgrep firefox)

At the moment, the above command will show host name lookup times for all processes, not just the firefox process. See #2813 for details (the reproducer from there can be used on non-NixOs systems, too).

Describe the solution you'd like

The bpf_attach_uprobe function from BCC that we use has a pid parameter. At the moment, we're only using the parameter for the BEGIN and END probes, this could be expanded to also pass the value from -p. We're already doing something similar for USDT probes.

@viktormalik viktormalik added the enhancement New feature or request, changes on existing features label Nov 1, 2023
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 16, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
@jordalgo
Copy link
Contributor

jordalgo commented Nov 16, 2023

Working on this one here: #2830

jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 16, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 17, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 17, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 19, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 20, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 21, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 24, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
jordalgo pushed a commit to jordalgo/bpftrace that referenced this issue Nov 25, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](bpftrace#2817)
danobi pushed a commit that referenced this issue Nov 29, 2023
This adds support for specifying the pid even when targeting
a uprobe/uretprobe in a library shared by multiple pids.

Example:
```
sudo bpftrace -p 1899508 -e 'uprobe:libc:getaddrinfo {
  print((comm, pid));
}
```

[Issue 2817](#2817)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request, changes on existing features
Projects
None yet
Development

No branches or pull requests

2 participants