Skip to content

Comments

Validate LDDW second-half instruction fields#764

Open
ppx123-web wants to merge 1 commit intoiovisor:mainfrom
ppx123-web:fix-lddw-second-half-validation
Open

Validate LDDW second-half instruction fields#764
ppx123-web wants to merge 1 commit intoiovisor:mainfrom
ppx123-web:fix-lddw-second-half-validation

Conversation

@ppx123-web
Copy link

Patch for issue 757
Fix the lddw instructon validation.

Signed-off-by: GOD_PPX <1251887477@qq.com>
Copilot AI review requested due to automatic review settings February 10, 2026 10:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens uBPF’s instruction validation to fully enforce the RFC 9669 requirements for the second half of an LDDW (64-bit immediate load), preventing malformed programs from loading successfully.

Changes:

  • Add validation that the second half of LDDW has dst == 0, src == 0, and offset == 0.
  • Add a new negative test case covering an LDDW second-half instruction with a non-zero dst field.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
vm/ubpf_vm.c Strengthens LDDW validation by enforcing zeroed register/offset fields in the second half.
tests/errors/err-lddw-second-half-invalid.data Adds regression coverage ensuring malformed LDDW second halves are rejected with the expected error.

Comment on lines +1867 to +1872
if (i + 1 >= num_insts || insts[i + 1].opcode != 0) {
*errmsg = ubpf_error("incomplete lddw at PC %d", i);
return false;
}
if (insts[i + 1].dst != 0 || insts[i + 1].src != 0 || insts[i + 1].offset != 0) {
*errmsg = ubpf_error("invalid lddw second half at PC %d", i + 1);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The incomplete lddw at PC %d error is also returned when insts[i+1].opcode != 0, which isn’t an “incomplete” LDDW but an invalid second-half instruction. Consider splitting the condition so the out-of-range case reports "incomplete lddw" while the opcode-mismatch case reports "invalid lddw second half" (at PC i+1) to make failures easier to diagnose and align with the expected semantics of the LDDW second half.

Copilot uses AI. Check for mistakes.
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.

1 participant