Skip to content

Disassembly support for Extended BPF#6204

Closed
Jagath-P wants to merge 13 commits into
rizinorg:devfrom
Jagath-P:ebpf_disassembly
Closed

Disassembly support for Extended BPF#6204
Jagath-P wants to merge 13 commits into
rizinorg:devfrom
Jagath-P:ebpf_disassembly

Conversation

@Jagath-P

@Jagath-P Jagath-P commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

I have used AI for doing some repeated stuff like writing all instructions op types, I have manually checked each instruction after the use.
...

Test plan

...

Closing issues

closes ebpf part of #4757

...

@notxvilka notxvilka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please rebase on top of the latest dev

@notxvilka notxvilka added this to the 0.9.0 milestone Apr 26, 2026
@Jagath-P
Jagath-P requested a review from notxvilka April 26, 2026 12:23
Comment thread librz/arch/p/asm/asm_bpf_cs.c Outdated
@codecov

codecov Bot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.85953% with 126 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.91%. Comparing base (5fa8210) to head (72ead9b).
⚠️ Report is 4 commits behind head on dev.

Files with missing lines Patch % Lines
librz/arch/p/analysis/analysis_bpf_cs.c 58.51% 90 Missing and 22 partials ⚠️
librz/arch/p/asm/asm_bpf_cs.c 51.72% 8 Missing and 6 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
librz/arch/p/asm/asm_bpf_cs.c 51.72% <51.72%> (ø)
librz/arch/p/analysis/analysis_bpf_cs.c 58.51% <58.51%> (ø)

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fa8210...72ead9b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@notxvilka notxvilka added the waiting-for-author Used to mark PRs where more work is needed label May 2, 2026
@Jagath-P

Jagath-P commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

I will be back to this PR after 4 days, need to finish up my semester exams

@Jagath-P
Jagath-P force-pushed the ebpf_disassembly branch from 228e3ae to cbde434 Compare May 11, 2026 06:50
@Jagath-P
Jagath-P requested a review from wargio May 11, 2026 10:14
@notxvilka

Copy link
Copy Markdown
Contributor

@Jagath-P please rebase again and resolve the conflicts

@Jagath-P
Jagath-P force-pushed the ebpf_disassembly branch 2 times, most recently from a9381bd to b7b2fed Compare May 25, 2026 08:05
Comment thread librz/arch/p/analysis/analysis_bpf_cs.c Outdated
Comment thread librz/arch/p/asm/asm_bpf_cs.c Outdated
@Jagath-P
Jagath-P force-pushed the ebpf_disassembly branch from b7b2fed to dafe935 Compare May 25, 2026 10:14

@Rot127 Rot127 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please increase test coverage to cover at lease:

  • all operand types
  • all jumps and calls. They are too important to not be tested.

Comment thread librz/arch/p/analysis/analysis_bpf_cs.c
Comment thread librz/arch/p/analysis/analysis_bpf_cs.c Outdated
case BPF_INS_JSGE:
case BPF_INS_JSLT:
case BPF_INS_JSLE:
if (insn->detail->bpf.op_count > 2) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also here.

Comment thread librz/arch/p/analysis/analysis_bpf_cs.c
Comment thread librz/arch/p/analysis/analysis_bpf_cs.c
Comment thread librz/arch/p/asm/asm_bpf_cs.c
Comment thread librz/arch/p/analysis/analysis_bpf_cs.c
@wargio

wargio commented Jun 3, 2026

Copy link
Copy Markdown
Member

this needs to be tested against cs4-5

@Jagath-P

Jagath-P commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

this needs to be tested against cs4-5

BPF doesn't exist in capstone v4 , It was introduced only from v5, Hence in meson.build file declared bpf plugins under capstone version >4 . Also I have added multiple checks in analysis_bpf_cs.c file for capstone v6 specific instructions

I have taken https://github.com/capstone-engine/capstone/blob/next/include/capstone/bpf.h as reference, and I took into account bpf.h file of next, v5,v6

even though how do i test locally using capstone past versions ? should i update my subprojects?

@notxvilka

Copy link
Copy Markdown
Contributor

this needs to be tested against cs4-5

BPF doesn't exist in capstone v4 , It was introduced only from v5, Hence in meson.build file declared bpf plugins under capstone version >4 . Also I have added multiple checks in analysis_bpf_cs.c file for capstone v6 specific instructions

I have taken https://github.com/capstone-engine/capstone/blob/next/include/capstone/bpf.h as reference, and I took into account bpf.h file of next, v5,v6

even though how do i test locally using capstone past versions ? should i update my subprojects?

See how it's done in our CI workflow: .github/workflows/ci.yml

@notxvilka

Copy link
Copy Markdown
Contributor

@Jagath-P please address the feedback so that this could land for the upcoming 0.9.0 release

@Jagath-P

Copy link
Copy Markdown
Contributor Author

@Jagath-P please address the feedback so that this could land for the upcoming 0.9.0 release

Yeah was busy in other works, will finish the work soon

@Rot127
Rot127 marked this pull request as draft June 14, 2026 17:06
@Jagath-P

Copy link
Copy Markdown
Contributor Author

I have gated the bpf plugin currently to capstone next only . As CS_API_MAJOR is 6 in both released v6 and next — version numbers alone cannot distinguish them. Latest BPF instructions (SDIV, SMOD, MOVSB, JLT32etc.) (present in the Linux Kernel 7.1.0 BPF ISA specification doc) are not present in any released Capstone version yet.
Support for already existing capstone v5,v6 can be added once Capstone cuts a release with full BPF ISA support.

@Jagath-P
Jagath-P requested review from Rot127 and notxvilka June 18, 2026 11:43
@Jagath-P
Jagath-P force-pushed the ebpf_disassembly branch 2 times, most recently from aceb55e to cb18ba8 Compare June 19, 2026 06:38
@notxvilka notxvilka modified the milestones: 0.9.0, 1.0.0 Jun 21, 2026
@Jagath-P
Jagath-P marked this pull request as ready for review June 29, 2026 08:20
@Jagath-P

Copy link
Copy Markdown
Contributor Author

@notxvilka @wargio @Rot127 can any of you review this once again

@Rot127 Rot127 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As CS_API_MAJOR is 6 in both released v6 and next

Please rebase. With the latest capstone there is the CS_VERSION_PRE_RELEASE you can use.

@Jagath-P It seems like the capstone v4/v5 workflows don't run properly if I push it to upstream/
Please address the comments here and then reopen the PR with a capstone- prefix in the branch name.

cs_free(insn, n);
return op->size;
}
RzAnalysisPlugin rz_analysis_plugin_bpf_cs = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

newline missing

.name = "bpf",
.desc = "Extended BPF analysis plugin",
.license = "LGPL3",
.arch = "bpf",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add your authorship

@notxvilka

Copy link
Copy Markdown
Contributor

Superseded by #6611

@notxvilka notxvilka closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rz-test RzAnalysis waiting-for-author Used to mark PRs where more work is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants