mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-24 11:59:58 +00:00
csource: use tmp dir in repeat loop when tmpdir flag is on
This commit is contained in:
parent
19015af815
commit
ed6891f2ed
@ -1760,7 +1760,7 @@ static int do_sandbox_namespace(int executor_pid, bool enable_tun)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
|
||||
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT) && defined(SYZ_USE_TMP_DIR))
|
||||
static void remove_dir(const char* dir)
|
||||
{
|
||||
DIR* dp;
|
||||
@ -1841,7 +1841,9 @@ retry:
|
||||
exitf("rmdir(%s) failed", dir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
|
||||
static uint64_t current_time_ms()
|
||||
{
|
||||
struct timespec ts;
|
||||
@ -1877,18 +1879,22 @@ void loop()
|
||||
{
|
||||
int iter;
|
||||
for (iter = 0;; iter++) {
|
||||
#ifdef SYZ_USE_TMP_DIR
|
||||
char cwdbuf[256];
|
||||
sprintf(cwdbuf, "./%d", iter);
|
||||
if (mkdir(cwdbuf, 0777))
|
||||
fail("failed to mkdir");
|
||||
#endif
|
||||
int pid = fork();
|
||||
if (pid < 0)
|
||||
fail("clone failed");
|
||||
if (pid == 0) {
|
||||
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
|
||||
setpgrp();
|
||||
#ifdef SYZ_USE_TMP_DIR
|
||||
if (chdir(cwdbuf))
|
||||
fail("failed to chdir");
|
||||
#endif
|
||||
#ifdef SYZ_TUN_ENABLE
|
||||
flush_tun();
|
||||
#endif
|
||||
@ -1910,7 +1916,9 @@ void loop()
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef SYZ_USE_TMP_DIR
|
||||
remove_dir(cwdbuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -859,7 +859,7 @@ static int do_sandbox_namespace(int executor_pid, bool enable_tun)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
|
||||
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT) && defined(SYZ_USE_TMP_DIR))
|
||||
// One does not simply remove a directory.
|
||||
// There can be mounts, so we need to try to umount.
|
||||
// Moreover, a mount can be mounted several times, so we need to try to umount in a loop.
|
||||
@ -948,7 +948,9 @@ retry:
|
||||
exitf("rmdir(%s) failed", dir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
|
||||
static uint64_t current_time_ms()
|
||||
{
|
||||
struct timespec ts;
|
||||
@ -984,18 +986,22 @@ void loop()
|
||||
{
|
||||
int iter;
|
||||
for (iter = 0;; iter++) {
|
||||
#ifdef SYZ_USE_TMP_DIR
|
||||
char cwdbuf[256];
|
||||
sprintf(cwdbuf, "./%d", iter);
|
||||
if (mkdir(cwdbuf, 0777))
|
||||
fail("failed to mkdir");
|
||||
#endif
|
||||
int pid = fork();
|
||||
if (pid < 0)
|
||||
fail("clone failed");
|
||||
if (pid == 0) {
|
||||
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
|
||||
setpgrp();
|
||||
#ifdef SYZ_USE_TMP_DIR
|
||||
if (chdir(cwdbuf))
|
||||
fail("failed to chdir");
|
||||
#endif
|
||||
#ifdef SYZ_TUN_ENABLE
|
||||
flush_tun();
|
||||
#endif
|
||||
@ -1017,7 +1023,9 @@ void loop()
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef SYZ_USE_TMP_DIR
|
||||
remove_dir(cwdbuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user