Title: fix: ensure eBPF verifier compliance by adding explicit fallback returns after tail calls by SiyuanSun0736 · Pull Request #16 · multikernel/kernelscript · GitHub
Open Graph Title: fix: ensure eBPF verifier compliance by adding explicit fallback returns after tail calls by SiyuanSun0736 · Pull Request #16 · multikernel/kernelscript
X Title: fix: ensure eBPF verifier compliance by adding explicit fallback returns after tail calls by SiyuanSun0736 · Pull Request #16 · multikernel/kernelscript
Description: Problem Definition The bpf_tail_call() helper in eBPF is not guaranteed to succeed. If the call fails (e.g., due to an invalid index or exceeding the call stack limit), execution continues at the instruction immediately following the call site. The eBPF verifier requires that every code path reaches a definitive termination point. Without an explicit return after a tail call, the verifier may reject the program as it cannot guarantee all paths exit. Mechanism of Change A new helper function get_tail_call_fallback_return has been implemented to determine the correct return value based on the program's execution context. This ensures that the generated C code includes a fallback return statement immediately following every bpf_tail_call. Context Mapping Logic The return value is determined by the current_function_context_type variable: Context Type (Some string) Fallback Return Value "xdp" XDP_PASS "tc" TC_ACT_OK None / Other 0 Technical Breakdown Code Generation: The logic modifies the emission of IRReturnTailCall and IRReturnCall. Instrumentation: Adds a C comment /* tail call fallback */ to the emitted return statement for traceability and debugging. Instruction Support: IRReturnTailCall: Explicit tail calls with specific indices. IRReturnCall: Generic calls mapped to tail call index 0. Match Arms: Coverage for both IRConstantPattern and IRDefaultPattern within IRMatchReturn instructions. Verification Results The implementation is verified via the following OCaml unit tests: test_tail_call_fallback_constant_arm_xdp: Confirms that in an XDP context, a constant match arm containing a tail call generates return XDP_PASS;. test_tail_call_fallback_default_arm_tc: Confirms that in a TC context, a default match arm generates return TC_ACT_OK;. test_return_call_fallback_generic_context: Confirms that when the context is undefined, the generator defaults to return 0; and correctly handles implicit tail calls (index 0).
Open Graph Description: Problem Definition The bpf_tail_call() helper in eBPF is not guaranteed to succeed. If the call fails (e.g., due to an invalid index or exceeding the call stack limit), execution continues at the i...
X Description: Problem Definition The bpf_tail_call() helper in eBPF is not guaranteed to succeed. If the call fails (e.g., due to an invalid index or exceeding the call stack limit), execution continues at the i...
Opengraph URL: https://github.com/multikernel/kernelscript/pull/16
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c81fa4df-60ba-79ca-a1e7-d0dd31de4aab |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C4B6:288596:639535:90D9E7:6A622A2F |
| html-safe-nonce | e2343015b6cd8caa0aacfb27715f8dc8a79036cd460c56f017a4da6a0c828d34 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNEI2OjI4ODU5Njo2Mzk1MzU6OTBEOUU3OjZBNjIyQTJGIiwidmlzaXRvcl9pZCI6IjEzNDk4NDI4Njk1Nzg3MzcxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 206c52fa333311cf557efd248b94fd83bfab89411a20ad58932751c56df60ab1 |
| hovercard-subject-tag | pull_request:3419658783 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/multikernel/kernelscript/pull/16/files |
| twitter:image | https://avatars.githubusercontent.com/u/100674758?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/100674758?s=400&v=4 |
| og:image:alt | Problem Definition The bpf_tail_call() helper in eBPF is not guaranteed to succeed. If the call fails (e.g., due to an invalid index or exceeding the call stack limit), execution continues at the i... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0e882415c7b47986d65f899389c870b31642bb1c6f36516eb042618596c60e62 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/multikernel/kernelscript git https://github.com/multikernel/kernelscript.git |
| octolytics-dimension-user_id | 202362072 |
| octolytics-dimension-user_login | multikernel |
| octolytics-dimension-repository_id | 1019261571 |
| octolytics-dimension-repository_nwo | multikernel/kernelscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1019261571 |
| octolytics-dimension-repository_network_root_nwo | multikernel/kernelscript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 230e2af5fc0870303dd4569d72d2bb393ed52c52 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width