-
Notifications
You must be signed in to change notification settings - Fork 172
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
wip: fix(plugin): enforce strict versioning for static plugins #2278
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gnosek The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Perf diff from master - unit tests
Heap diff from master - unit tests
Heap diff from master - scap file
Benchmarks diff from master
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2278 +/- ##
==========================================
+ Coverage 75.32% 75.34% +0.01%
==========================================
Files 280 280
Lines 34556 34582 +26
Branches 5902 5902
==========================================
+ Hits 26031 26055 +24
- Misses 8525 8527 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/milestone 0.21.0 |
478bf4b
to
6cfa7ba
Compare
6cfa7ba
to
c0f346b
Compare
API 3.10 changed the layout of the plugin_api struct in an ABI-incompatible way. This does not matter for shared library plugins, but statically linked plugins do depend on binary compatibility between the two structs. Signed-off-by: Grzegorz Nosek <[email protected]>
`extract_plugin_abi.py` parses the output from pahole describing the `plugin_api` struct (with the offsets and sizes of all fields) and generates a `plugin_abi.h` header with static asserts to ensure the ABI is up to date (on x86_64/Linux). `diff_plugin_abi.py` takes two copies of the generated plugin_abi.h files (presumably, one from the repo and a freshly generated one) and raises an error if: * a struct member has been moved/removed without ABI version bump * the ABI version has been increased without breaking changes Note: adding a field at the end of the plugin_api struct does not count as a breaking change. Signed-off-by: Grzegorz Nosek <[email protected]>
The current ABI is arbitrarily chosen as v3 (to match the major API version). Note: when making incompatible ABI changes, this file will prevent the build from succeeding. When you're making ABI changes on purpose, the easiest way is to remove everything but the ABI version `#define` from plugin_abi.h and once everything builds, regenerate plugin_abi.h (see tools/plugin_abi/extract_plugin_abi.py) Signed-off-by: Grzegorz Nosek <[email protected]>
c0f346b
to
dc3a941
Compare
Introduce an explicit ABI version field to plugin_api, as well as a size field. This allows us to explicitly detect incompatible ABIs, but also to detect struct changes within an ABI version. The size field is actually pretty important (maybe more than the actual version field, as long as get_api_version can be easily found), because it's the only way to know how big the plugin-provided struct actually is. With plugins targeting older API versions, we're doing a basically guaranteed out of bounds read otherwise (if the plugin_api struct in the framework is larger than what the plugin exports). Signed-off-by: Grzegorz Nosek <[email protected]>
dc3a941
to
815dc2d
Compare
You should add |
Signed-off-by: Grzegorz Nosek <[email protected]>
Statically linked plugins have stricter version requirements, since they rely on the layout of the
plugin_api
struct. So, when loading a statically linked plugin, we enforce the plugin API to be exactly equal (up to the patch level) to the framework API.What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: