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

link/kprobe: specify symbol offset #613

Closed
wants to merge 3 commits into from
Closed

link/kprobe: specify symbol offset #613

wants to merge 3 commits into from

Conversation

xpu22
Copy link
Contributor

@xpu22 xpu22 commented Mar 29, 2022

Signed-off-by: Tonghao Zhang zhangtonghao@didiglobal.com

Signed-off-by: Tonghao Zhang <zhangtonghao@didiglobal.com>
link/kprobe.go Outdated Show resolved Hide resolved
Signed-off-by: Tonghao Zhang <zhangtonghao@didiglobal.com>
Copy link
Collaborator

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing some comments/documentation. Looks fine otherwise.

link/kprobe.go Show resolved Hide resolved
@@ -49,6 +49,8 @@ type KprobeOptions struct {
//
// Needs kernel 5.15+.
Cookie uint64
// Kprobe symbol offset.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs more context. How is it used? Why is it necessary? How would the caller determine the correct offset to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, This offset is used for kprobe, because some functions in kernel is static or inline, we can't insert one probe. but we can use probe the caller with offset. This "offset" is same as tracefs kprobe_events

https://www.kernel.org/doc/html/latest/trace/kprobetrace.html

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Kprobe symbol offset.
// Offset of the kprobe relative to the traced symbol.
// Can be used to insert kprobes at arbitrary offsets in kernel functions,
// e.g. in places where functions have been inlined.

@ti-mo
Copy link
Collaborator

ti-mo commented Mar 30, 2022

Adding a test similar to TestUprobeToken would be nice, as well as one where the offset is set and meaningfully used.

@ti-mo ti-mo changed the title link/kprobe: Allow to parse symbol offset link/kprobe: specify symbol offset Mar 30, 2022
Signed-off-by: Tonghao Zhang <zhangtonghao@didiglobal.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants