qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fuzz: Disable QEMU's signal handlers


From: Alexander Bulekov
Subject: Re: [PATCH] fuzz: Disable QEMU's signal handlers
Date: Tue, 13 Oct 2020 13:02:20 -0400

On 201013 1750, Darren Kenny wrote:
> Hi Alex,
> 
> This mentions the use of atexit() to perform some cleanup, but I'm not
> seeing that being added here, should it be?
> 

That sentence was not clear.. I meant that the developer can
(optionally) use atexit when writing a new fuzz-target to perform
cleanup. For example see:
https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg03735.html
It would be nice to clean-up the drive files created in that fuzzer with
atexit. However, right now that will not do any good, since clean exit
signals are ignored.
-Alex

> Thanks,
> 
> Darren.
> 
> On Tuesday, 2020-10-13 at 11:29:20 -04, Alexander Bulekov wrote:
> > With the fuzzer, we never call main_loop_should_exit, since we manually
> > call main_loop_wait. This means that the only way to terminate the
> > fuzzer is with SIGKILL. Disable the signal handlers, so there are
> > reasonable ways to terminate the fuzzer and use atexit() to clean-up
> > after the fuzzer.
> >
> > Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
> > ---
> >  tests/qtest/fuzz/fuzz.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
> > index d926c490c5..eb0070437f 100644
> > --- a/tests/qtest/fuzz/fuzz.c
> > +++ b/tests/qtest/fuzz/fuzz.c
> > @@ -217,5 +217,13 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char 
> > ***envp)
> >      /* re-enable the rcu atfork, which was previously disabled in 
> > qemu_init */
> >      rcu_enable_atfork();
> >  
> > +    /*
> > +     * Disable QEMU's signal handlers, since we manually control the 
> > main_loop,
> > +     * and don't check for main_loop_should_exit
> > +     */
> > +    signal(SIGINT, SIG_DFL);
> > +    signal(SIGHUP, SIG_DFL);
> > +    signal(SIGTERM, SIG_DFL);
> > +
> >      return 0;
> >  }
> > -- 
> > 2.28.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]