Skip to content

Commit 45222b9

Browse files
a1xndrhuth
authored andcommitted
fuzz: fix broken qtest check at rcu_disable_atfork
The qtest_enabled check introduced in d6919e4 always returns false, as it is called prior to configure_accelerators(). Instead of trying to skip rcu_disable_atfork in qemu_main, simply call rcu_enable_atfork in the fuzzer, after qemu_main returns. Reported-by: Thomas Huth <[email protected]> Signed-off-by: Alexander Bulekov <[email protected]> Message-Id: <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent eb6490f commit 45222b9

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

softmmu/vl.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,17 +3832,7 @@ void qemu_init(int argc, char **argv, char **envp)
38323832
machine_class);
38333833

38343834
os_daemonize();
3835-
3836-
/*
3837-
* If QTest is enabled, keep the rcu_atfork enabled, since system processes
3838-
* may be forked testing purposes (e.g. fork-server based fuzzing) The fork
3839-
* should happen before a signle cpu instruction is executed, to prevent
3840-
* deadlocks. See commit 73c6e40, rcu: "completely disable pthread_atfork
3841-
* callbacks as soon as possible"
3842-
*/
3843-
if (!qtest_enabled()) {
3844-
rcu_disable_atfork();
3845-
}
3835+
rcu_disable_atfork();
38463836

38473837
if (pid_file && !qemu_write_pidfile(pid_file, &err)) {
38483838
error_reportf_err(err, "cannot create PID file: ");

tests/qtest/fuzz/fuzz.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,8 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
211211

212212
qemu_init(result.we_wordc, result.we_wordv, NULL);
213213

214+
/* re-enable the rcu atfork, which was previously disabled in qemu_init */
215+
rcu_enable_atfork();
216+
214217
return 0;
215218
}

0 commit comments

Comments
 (0)