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

Make kaddr() report failure for unknown kernel symbols #1836

Merged
merged 1 commit into from
May 11, 2021

Conversation

danobi
Copy link
Member

@danobi danobi commented May 10, 2021

Previously, bad kaddr() calls would silently fail and return 0. This is
bad b/c you silently get bad data. Let's report and error and fail
instead.

Checklist
  • Language changes are updated in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

Previously, bad kaddr() calls would silently fail and return 0. This is
bad b/c you silently get bad data. Let's report and error and fail
instead.
@@ -612,6 +612,8 @@ void CodegenLLVM::visit(Call &call)
uint64_t addr;
auto name = bpftrace_.get_string_literal(call.vargs->at(0));
addr = bpftrace_.resolve_kname(name);
if (!addr)
throw std::runtime_error("Failed to resolve kernel symbol: " + name);
Copy link
Member

Choose a reason for hiding this comment

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

we should be able to use LOG here

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about that. codegen isn't hooked up to check for error messages like semantic_analyser is. Could LOG(FATAL) but it'd be better if we had a nice message instead

Copy link
Member Author

Choose a reason for hiding this comment

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

Unless you mean we should in the future. In which case my suggestion would be that this shouldn't happen in codegen anyways. I'll probably clean this up as part of my AOT project

Copy link
Member

Choose a reason for hiding this comment

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

ah yeah, only FATAL works here.

@danobi danobi merged commit 3b60ff1 into bpftrace:master May 11, 2021
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.

2 participants