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

fix vm.due_insn_count subtract overflow when enable_instruction_meter=false #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hycinth22
Copy link

@hycinth22 hycinth22 commented Jan 26, 2025

I found a corner case.

if config.enable_instruction_meter=false & jit is off,
vm.due_insn_count subtract overflow encoutered at

self.vm.due_insn_count = self.vm.previous_instruction_meter - self.vm.due_insn_count;

that's because we set previous_instruction_meter to 0 when config.enable_instruction_meter is set to false

sbpf/src/vm.rs

Lines 347 to 352 in 946f7d9

let initial_insn_count = if config.enable_instruction_meter {
self.context_object_pointer.get_remaining()
} else {
0
};
self.previous_instruction_meter = initial_insn_count;

I confirmed that it exists in interpreter mode,
but I'm not sure about the behavior in JIT mode (request for review)

@hycinth22 hycinth22 marked this pull request as ready for review January 26, 2025 12:17
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