Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Hot Fix: Remove unwrap in vm::bind_syscall_context_object() (#135)
Browse files Browse the repository at this point in the history
* Turns unwrap into Err and adds hash / slot / address for context.

* Bump version to v0.2.4
  • Loading branch information
Lichtso authored Jan 26, 2021
1 parent d33462e commit d4c524c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "solana_rbpf"
version = "0.2.3"
version = "0.2.4"
description = "Virtual machine and JIT compiler for eBPF programs"
authors = ["Solana Maintainers <[email protected]>"]
repository = "https://github.com/solana-labs/rbpf"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ so it should work out of the box by adding it as a dependency in your

```toml
[dependencies]
solana_rbpf = "0.2.2"
solana_rbpf = "0.2.4"
```

You can also use the development version from this GitHub repository. This
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rbpf_cli"
version = "0.2.3"
version = "0.2.4"
description = "CLI to test and analyze eBPF programs"
authors = ["Solana Maintainers <[email protected]>"]
repository = "https://github.com/solana-labs/rbpf"
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl AnalysisResult {

fn main() {
let matches = App::new("Solana RBPF CLI")
.version("0.2.3")
.version("0.2.4")
.author("Solana Maintainers <[email protected]>")
.about("CLI to test and analyze eBPF programs")
.arg(
Expand Down
11 changes: 7 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ pub enum EbpfError<E: UserDefinedError> {
#[error("ELF error: {0}")]
ELFError(#[from] ELFError),
/// Syscall was already registered before
#[error("syscall was already registered before")]
SycallAlreadyRegistered,
#[error("syscall #{0} was already registered before")]
SycallAlreadyRegistered(usize),
/// Syscall was not registered before bind
#[error("syscall #{0} was not registered before bind")]
SyscallNotRegistered(usize),
/// Syscall already has a bound context object
#[error("syscall already has a bound context object")]
SycallAlreadyBound,
#[error("syscall #{0} already has a bound context object")]
SyscallAlreadyBound(usize),
/// Exceeded max BPF to BPF call depth
#[error("exceeded max BPF to BPF call depth of {1} at instruction #{0}")]
CallDepthExceeded(usize, usize),
Expand Down
10 changes: 6 additions & 4 deletions src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl SyscallRegistry {
.insert(function, context_object_slot)
.is_some()
{
Err(EbpfError::SycallAlreadyRegistered)
Err(EbpfError::SycallAlreadyRegistered(hash as usize))
} else {
Ok(())
}
Expand Down Expand Up @@ -518,15 +518,17 @@ impl<'a, E: UserDefinedError, I: InstructionMeter> EbpfVm<'a, E, I> {
Some(hash) => {
syscall_registry
.lookup_syscall(hash)
.unwrap()
.ok_or(EbpfError::SyscallNotRegistered(hash as usize))?
.context_object_slot
}
None => syscall_registry
.lookup_context_object_slot(fat_ptr.vtable.methods[0] as u64)
.unwrap(),
.ok_or(EbpfError::SyscallNotRegistered(
fat_ptr.vtable.methods[0] as usize,
))?,
};
if !self.syscall_context_objects[SYSCALL_CONTEXT_OBJECTS_OFFSET + slot].is_null() {
Err(EbpfError::SycallAlreadyBound)
Err(EbpfError::SyscallAlreadyBound(slot))
} else {
self.syscall_context_objects[SYSCALL_CONTEXT_OBJECTS_OFFSET + slot] = fat_ptr.data;
// Keep the dyn trait objects so that they can be dropped properly later
Expand Down

0 comments on commit d4c524c

Please sign in to comment.