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: (u|k)probe: don't treat EINVAL as os.ErrNotExist #751

Merged
merged 2 commits into from Jul 29, 2022

Conversation

ti-mo
Copy link
Collaborator

@ti-mo ti-mo commented Jul 28, 2022

This is a follow-up to #745.

No longer treat EINVAL from creating u/k(ret)probes as os.ErrNotExist, since EINVAL has many potential causes. This is a potentially breaking change, since callers scanning valid instruction offsets in symbols must now expect both os.ErrNotExist as well as os.EINVAL, depending on the kernel version and architecture.

Make errors shorter and more specific, e.g. 'bad insn boundary' no longer includes a 'not found' string. Token is now included in all errors, even unrecognized ones.

@ti-mo ti-mo requested review from lmb and mmat11 July 28, 2022 09:22
@mmat11
Copy link
Collaborator

mmat11 commented Jul 28, 2022

am I wrong or we are not catching EINVAL at all?

@ti-mo
Copy link
Collaborator Author

ti-mo commented Jul 28, 2022

This may be the sleep deprivation talking, but EINVAL would be handled by the err != nil catch-all.

@mmat11
Copy link
Collaborator

mmat11 commented Jul 28, 2022

This may be the sleep deprivation talking, but EINVAL would be handled by the err != nil catch-all.

🙈 true, didn't notice it, LGTM!

looks like a 4.14 test needs to be adjusted

@lmb
Copy link
Collaborator

lmb commented Jul 28, 2022

Thanks Timo!

lmb and others added 2 commits July 29, 2022 12:30
Running TestUprobeExtWithOpts on arm64 currently gives a weird error:

    uprobe_test.go:101: creating perf_uprobe PMU: symbol 'open+0x1' not found: file does not exist

Investigating via strace shows that perf_event_open returns EINVAL:

    perf_event_open({type=0x7 /* PERF_TYPE_??? */, size=PERF_ATTR_SIZE_VER1, ...}, -1, 0, -1, PERF_FLAG_FD_CLOEXEC) = -1 EINVAL (Invalid argument)

We map this to ENOENT since older kernels don't return a useful error
when the target function doesn't exist. The example above shows that this is
too broad.

Stop mapping EINVAL to ENOENT.

Co-authored-by: Timo Beckers <timo@isovalent.com>
The tracefs probes have used a 'token' to represent their ksym:offset
tuples for some time, but PMUs take those values as separate fields
in the syscall. This commit harmonizes the two, making errors more consistent
across both APIs.

Also makes sure the token is included in all errors, regardless of the type.

Signed-off-by: Timo Beckers <timo@isovalent.com>
@ti-mo ti-mo merged commit 39ee31d into cilium:master Jul 29, 2022
@ti-mo ti-mo deleted the tb/perf-event-einval branch July 29, 2022 10:38
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