-
Notifications
You must be signed in to change notification settings - Fork 5
Implement load data as code in syscall tracer #22
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
Changes from 1 commit
7e251e4
e164d26
54637cc
9bb597d
2f60f88
a96306e
8483a81
6dc02e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,10 @@ message IoData { | |
| uint64 additional_length = 2; | ||
| } | ||
|
|
||
| message IoDataAsCode { | ||
|
||
| bytes available_data = 1; | ||
| } | ||
|
|
||
| message Fds { | ||
| repeated uint64 fds = 1; | ||
| } | ||
|
|
@@ -30,8 +34,9 @@ message Syscall { | |
| // 2) split them into 3 different fields. | ||
| uint64 success_output_data = 2; | ||
| IoData io_data = 3; | ||
| Terminated terminated = 4; | ||
| Fds fds = 5; | ||
| IoDataAsCode io_data_as_code = 4; | ||
| Terminated terminated = 5; | ||
| Fds fds = 6; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,14 +175,28 @@ impl SyscallImpls for ProtobufBasedSyscallImpls { | |
|
|
||
| fn load_cell_code( | ||
| &self, | ||
| _buf_ptr: *mut u8, | ||
| _len: usize, | ||
| buf_ptr: *mut u8, | ||
| len: usize, | ||
| _content_offset: usize, | ||
| _content_size: usize, | ||
| _index: usize, | ||
| _source: Source, | ||
| ) -> Result<(), Error> { | ||
| panic!("Load cell data as code is not suported!"); | ||
| match self.syscall() { | ||
|
||
| Some(traces::syscall::Value::ReturnWithCode(code)) => { | ||
| if code != 0 { | ||
| return Err(Error::try_from(code as u64).unwrap()); | ||
| } | ||
| Ok(()) | ||
| } | ||
| Some(traces::syscall::Value::IoDataAsCode(io_data_as_code)) => { | ||
| unsafe { | ||
| std::ptr::copy_nonoverlapping(io_data_as_code.available_data.as_ptr(), buf_ptr, len); | ||
|
||
| } | ||
| Ok(()) | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
|
|
||
| fn load_cell_data(&self, buf: &mut [u8], offset: usize, _index: usize, _source: Source) -> IoResult { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this, the whole idea of
SyscallImplsSynchronousWrapperis that underlyingimplsshould handle the full syscall. What's the storing and permission setting doing here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For storing, I wrote it based on
load_data: https://github.com/nervosnetwork/ckb-vm-contrib/blob/main/ckb-vm-fuzzing-utils/src/lib.rs#L82For permission setting, replied here: #22 (comment)