Re: [PATCH] kcov, usb: disable interrupts in kcov_remote_start_usb_softirq
From: Andrey Konovalov
Date: Tue May 21 2024 - 16:47:06 EST
On Tue, May 21, 2024 at 6:35 AM Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
>
> On Mon, 20 May 2024 at 22:59, <andrey.konovalov@xxxxxxxxx> wrote:
> >
> > From: Andrey Konovalov <andreyknvl@xxxxxxxxx>
> >
> > After commit 8fea0c8fda30 ("usb: core: hcd: Convert from tasklet to BH
> > workqueue"), usb_giveback_urb_bh() runs in the BH workqueue with
> > interrupts enabled.
> >
> > Thus, the remote coverage collection section in usb_giveback_urb_bh()->
> > __usb_hcd_giveback_urb() might be interrupted, and the interrupt handler
> > might invoke __usb_hcd_giveback_urb() again.
> >
> > This breaks KCOV, as it does not support nested remote coverage collection
> > sections within the same context (neither in task nor in softirq).
> >
> > Update kcov_remote_start/stop_usb_softirq() to disable interrupts for the
> > duration of the coverage collection section to avoid nested sections in
> > the softirq context (in addition to such in the task context, which are
> > already handled).
>
> Besides the issue pointed by the test robot:
>
> Acked-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
>
> Thanks for fixing this.
Thanks for the ack!
> This section of code does not rely on reentrancy, right? E.g. one
> callback won't wait for completion of another callback?
I think all should be good. Before the BH workqueue change, the code
ran with interrupts disabled.
> At some point we started seeing lots of "remote cover enable write
> trace failed (errno 17)" errors while running syzkaller. Can these
> errors be caused by this issue?
This looks like a different issue. I also noticed this when I tried
running a log with a bunch of USB programs via syz-execprog. Not sure
why this happens, but I still see it with this patch applied.
Thanks!