Skip to content

Commit

Permalink
executor: use different remote kcov handles each time
Browse files Browse the repository at this point in the history
It serves two purposes:
1) Ignore the remote coverage that was initiated by the already exited
   executor instances.
2) Circumvent the KCOV bug that sometimes results in dangling remote
   kcov handles. The bug is fixed in [1], but it will take time for it
   to reach all the kernels we fuzz.

Fixes google#4626.

[1] https://lore.kernel.org/all/[email protected]/
  • Loading branch information
a-nogikh committed Jun 12, 2024
1 parent f815599 commit dc1bf5b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions executor/executor_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,16 @@ static void cover_enable(cover_t* cov, bool collect_comps, bool extra)
.area_size = kExtraCoverSize,
.num_handles = 1,
};
arg.common_handle = kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, procid + 1);
arg.handles[0] = kcov_remote_handle(KCOV_SUBSYSTEM_USB, procid + 1);

// Let's use a different kcov remote handle each restart -- we don't want to
// see the remote coverage triggered by the already exited executors.
struct timeval curr_time;
gettimeofday(&curr_time, NULL);
uint64 current_usec = curr_time.tv_sec * 1000000 + curr_time.tv_usec;
// Combine procid with the current time.
uint64 instance_id = (current_usec & KCOV_INSTANCE_MASK & ~0xF) | (procid & 0xF);
arg.common_handle = kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, instance_id);
arg.handles[0] = kcov_remote_handle(KCOV_SUBSYSTEM_USB, instance_id);
if (ioctl(cov->fd, KCOV_REMOTE_ENABLE, &arg))
exitf("remote cover enable write trace failed");
}
Expand Down

0 comments on commit dc1bf5b

Please sign in to comment.