Skip to content

Commit a6f0632

Browse files
Merge pull request #59 from kokkonisd/master
Snapshot mode: fix incompatibility with libcompcov.so
2 parents 40033af + 32d7980 commit a6f0632

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

accel/tcg/cpu-exec.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,18 @@ static void collect_memory_snapshot(void) {
176176
char *line = NULL;
177177
size_t len = 0;
178178
ssize_t read;
179+
uint64_t afl_shm_inode = 0;
180+
char *afl_shm_id_str = getenv(SHM_ENV_VAR);
179181

180182
fp = fopen("/proc/self/maps", "r");
181183
if (fp == NULL) {
182184
fprintf(stderr, "[AFL] ERROR: cannot open /proc/self/maps\n");
183185
exit(1);
184186
}
187+
188+
if (afl_shm_id_str) {
189+
afl_shm_inode = atoi(afl_shm_id_str);
190+
}
185191

186192
size_t memory_snapshot_allocd = 32;
187193
if (!lkm_snapshot)
@@ -208,6 +214,11 @@ static void collect_memory_snapshot(void) {
208214
if (page_check_range(h2g(min), max - min, flags) == -1)
209215
continue;
210216

217+
// When `libcompcov.so` is used, the shared memory used to track coverage
218+
// is picked up here. Obviously, we don't want to reset that, as that
219+
// would erase coverage tracking, so we skip it.
220+
if (afl_shm_id_str && inode == afl_shm_inode) continue;
221+
211222
if (lkm_snapshot) {
212223

213224
afl_snapshot_include_vmrange((void*)min, (void*)max);

0 commit comments

Comments
 (0)