Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a8a22655
Unverified
Commit
a8a22655
authored
Jul 13, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Fuzz test syscalls
parent
8cf3f96f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
377 additions
and
7 deletions
+377
-7
fpvm_test.go
cannon/mipsevm/fpvm_test.go
+360
-0
mips.go
cannon/mipsevm/mips.go
+17
-7
No files found.
cannon/mipsevm/fpvm_test.go
0 → 100644
View file @
a8a22655
This diff is collapsed.
Click to expand it.
cannon/mipsevm/mips.go
View file @
a8a22655
...
...
@@ -6,6 +6,16 @@ import (
"io"
)
const
(
sysMmap
=
4090
sysBrk
=
4045
sysClone
=
4120
sysExitGroup
=
4246
sysRead
=
4003
sysWrite
=
4004
sysFcntl
=
4055
)
func
(
m
*
InstrumentedState
)
readPreimage
(
key
[
32
]
byte
,
offset
uint32
)
(
dat
[
32
]
byte
,
datLen
uint32
)
{
preimage
:=
m
.
lastPreimage
if
key
!=
m
.
lastPreimageKey
{
...
...
@@ -43,7 +53,7 @@ func (m *InstrumentedState) handleSyscall() error {
//fmt.Printf("syscall: %d\n", syscallNum)
switch
syscallNum
{
case
4090
:
// mmap
case
sysMmap
:
sz
:=
a1
if
sz
&
PageAddrMask
!=
0
{
// adjust size to align with page size
sz
+=
PageSize
-
(
sz
&
PageAddrMask
)
...
...
@@ -56,15 +66,15 @@ func (m *InstrumentedState) handleSyscall() error {
v0
=
a0
//fmt.Printf("mmap hint 0x%x size 0x%x\n", v0, sz)
}
case
4045
:
// brk
case
sysBrk
:
v0
=
0x40000000
case
4120
:
// clone (not supported)
case
sysClone
:
// clone (not supported)
v0
=
1
case
4246
:
// exit_group
case
sysExitGroup
:
m
.
state
.
Exited
=
true
m
.
state
.
ExitCode
=
uint8
(
a0
)
return
nil
case
4003
:
// read
case
sysRead
:
// args: a0 = fd, a1 = addr, a2 = count
// returns: v0 = read, v1 = err code
switch
a0
{
...
...
@@ -98,7 +108,7 @@ func (m *InstrumentedState) handleSyscall() error {
v0
=
0xFFffFFff
v1
=
MipsEBADF
}
case
4004
:
// write
case
sysWrite
:
// args: a0 = fd, a1 = addr, a2 = count
// returns: v0 = written, v1 = err code
switch
a0
{
...
...
@@ -144,7 +154,7 @@ func (m *InstrumentedState) handleSyscall() error {
v0
=
0xFFffFFff
v1
=
MipsEBADF
}
case
4055
:
// fcntl
case
sysFcntl
:
// args: a0 = fd, a1 = cmd
if
a1
==
3
{
// F_GETFL: get file descriptor flags
switch
a0
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment