Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libzafl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
libzafl
Commits
9e3b13f6
Commit
9e3b13f6
authored
6 years ago
by
Anh Nguyen-Tuong
Browse files
Options
Downloads
Patches
Plain Diff
Rename to tracemap
parent
b3ca09bd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libzafl.cpp
+12
-18
12 additions, 18 deletions
src/libzafl.cpp
with
12 additions
and
18 deletions
src/libzafl.cpp
+
12
−
18
View file @
9e3b13f6
...
...
@@ -29,15 +29,8 @@
#include
"libzafl.hpp"
//
// code adapted from libAflDynist.cpp
// to perform AFL handshaking with master process
// see afl documentation for handshaking description
//
// these are externally visible so that Zipr transformations
// can access directly
u8
*
zafl_trace_bits
;
// these are externally visible so that Zipr transformations can access directly
u8
*
zafl_trace_map
;
unsigned
short
zafl_prev_id
;
static
s32
shm_id
;
/* ID of the SHM region */
...
...
@@ -55,7 +48,7 @@ void __attribute__((constructor)) zafl_initAflForkServer();
static
void
zafl_setupSharedMemory
()
{
zafl_prev_id
=
0
;
zafl_trace_
bits
=
NULL
;
zafl_trace_
map
=
NULL
;
char
*
shm_env_var
=
getenv
(
SHM_ENV_VAR
);
if
(
!
shm_env_var
)
{
...
...
@@ -63,8 +56,8 @@ static void zafl_setupSharedMemory()
return
;
}
shm_id
=
atoi
(
shm_env_var
);
zafl_trace_
bits
=
(
u8
*
)
shmat
(
shm_id
,
NULL
,
0
);
if
(
zafl_trace_
bits
==
(
u8
*
)
-
1
)
{
zafl_trace_
map
=
(
u8
*
)
shmat
(
shm_id
,
NULL
,
0
);
if
(
zafl_trace_
map
==
(
u8
*
)
-
1
)
{
PRINT_ERROR
(
"shmat"
);
return
;
}
...
...
@@ -77,16 +70,16 @@ void zafl_initAflForkServer()
if
(
!
shared_memory_is_setup
)
zafl_setupSharedMemory
();
if
(
!
zafl_trace_
bits
)
{
zafl_trace_
bits
=
(
u8
*
)
malloc
(
MAP_SIZE
);
printf
(
"no shmem detected: fake it: zafl_trace_
bits
= %p, malloc_size(%d)
\n
"
,
zafl_trace_
bits
,
MAP_SIZE
);
if
(
!
zafl_trace_
map
)
{
zafl_trace_
map
=
(
u8
*
)
malloc
(
MAP_SIZE
);
printf
(
"no shmem detected: fake it: zafl_trace_
map
= %p, malloc_size(%d)
\n
"
,
zafl_trace_
map
,
MAP_SIZE
);
}
int
n
=
write
(
FORKSRV_FD
+
1
,
&
__afl_temp_data
,
4
);
if
(
n
!=
4
)
{
PRINT_ERROR
(
"Error writting fork server -- faking global memory
\n
"
);
perror
(
"zafl_initAflForkServer()"
);
printf
(
"zafl_trace_
bits
= %p, FORKSVR_FD(%d)
\n
"
,
zafl_trace_
bits
,
FORKSRV_FD
);
printf
(
"zafl_trace_
map
= %p, FORKSVR_FD(%d)
\n
"
,
zafl_trace_
map
,
FORKSRV_FD
);
return
;
}
...
...
@@ -103,11 +96,12 @@ void zafl_initAflForkServer()
return
;
}
if
(
__afl_fork_pid
==
0
)
{
// child
close
(
FORKSRV_FD
);
close
(
FORKSRV_FD
+
1
);
break
;
}
else
{
// parent
stuff
// parent
n
=
write
(
FORKSRV_FD
+
1
,
&
__afl_fork_pid
,
4
);
pid_t
temp_pid
=
waitpid
(
__afl_fork_pid
,
&
__afl_temp_data
,
2
);
if
(
temp_pid
==
0
)
{
...
...
@@ -121,6 +115,6 @@ void zafl_initAflForkServer()
// for debugging purposes only
// basic block instrumentations will be inlined via a Zipr transformation
void
zafl_bbInstrument
(
unsigned
short
id
)
{
zafl_trace_
bits
[
zafl_prev_id
^
id
]
++
;
zafl_trace_
map
[
zafl_prev_id
^
id
]
++
;
zafl_prev_id
=
id
>>
1
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment