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

btf: fix LoadKernelSpec #145

Merged
merged 1 commit into from Oct 5, 2020
Merged

btf: fix LoadKernelSpec #145

merged 1 commit into from Oct 5, 2020

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Oct 1, 2020

The current code fails to find any kernel spec because the call to
Sprintf may contain too many or too few arguments. The result then
contains %!s(MISSING), etc. which of course triggers an error when
trying to open the path.

Another problem is that the function tries other filenames if reading
the BTF itself fails for some reason. In that case it will most likely
return ErrNotFound, and the user is none the wiser: we found a BTF
but couldn't load it.

Change the code so that we return any error from the BTF loading itself.

The current code fails to find any kernel spec because the call to
Sprintf may contain too many or too few arguments. The result then
contains %!s(MISSING), etc. which of course triggers an error when
trying to open the path.

Another problem is that the function tries other filenames if reading
the BTF itself fails for some reason. In that case it will most likely
return ErrNotFound, and the user is none the wiser: we found a BTF
but couldn't load it.

Change the code so that we return any error from the BTF loading itself.
@lmb
Copy link
Collaborator Author

lmb commented Oct 1, 2020

cc @brycekahle this is why CI fails. Now I'm mystified why it worked on the other kernels 🤷

continue
}
return spec, nil
return loadSpecFromVmlinux(fh)
Copy link
Contributor

Choose a reason for hiding this comment

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

There isn't a guarantee that these files will have a .BTF section. Should we keep searching if that is the case?

Copy link
Collaborator Author

@lmb lmb Oct 2, 2020

Choose a reason for hiding this comment

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

I think that's unlikely to help: most systems will only have a single path where vmlinux is located (since it's a single package). Trying other paths has the downside that we return ErrNotFound instead of an error describing why we can't use the existing BTF. That is really confusing to users (and to me when I started to look into the issue).

@lmb lmb merged commit edc4db4 into master Oct 5, 2020
@lmb lmb deleted the lmb/fix-spec-load branch October 5, 2020 07:57
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

2 participants