lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 7 Oct 2020 21:54:57 +0200
From:   Andrey Konovalov <andreyknvl@...gle.com>
To:     Alan Stern <stern@...land.harvard.edu>
Cc:     Dmitry Vyukov <dvyukov@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        USB list <linux-usb@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Shuah Khan <shuah@...nel.org>,
        Alexander Potapenko <glider@...gle.com>,
        Marco Elver <elver@...gle.com>,
        Aleksandr Nogikh <nogikh@...gle.com>,
        Nazime Hande Harputluoglu <handeharputlu@...gle.com>
Subject: Re: [PATCH] kcov, usb, vhost: specify contexts for remote coverage sections

On Wed, Oct 7, 2020 at 9:29 PM Alan Stern <stern@...land.harvard.edu> wrote:
>
> On Wed, Oct 07, 2020 at 07:30:51PM +0200, Andrey Konovalov wrote:
> > Currently there's a KCOV remote coverage collection section in
> > __usb_hcd_giveback_urb(). Initially that section was added based on the
> > assumption that usb_hcd_giveback_urb() can only be called in interrupt
> > context as indicated by a comment before it.
> >
> > As it turns out, it's actually valid to call usb_hcd_giveback_urb() in task
> > context, provided that the caller turned off the interrupts; USB/IP actually
> > does that. This can lead to a nested KCOV remote coverage collection
> > sections both trying to collect coverage in task context. This isn't
> > supported by KCOV, and leads to a WARNING.
> >
> > The approach this patch takes is to annotate every call of kcov_remote_*()
> > callbacks with the context those callbacks are supposed to be executed in.
> > If the current context doesn't match the mask provided to a callback,
> > that callback is ignored. KCOV currently only supports collecting remote
> > coverage in two contexts: task and softirq.
> >
> > As the result, the coverage from USB/IP related usb_hcd_giveback_urb() calls
> > won't be collected, but the WARNING is fixed.
> >
> > A potential future improvement would be to support nested remote coverage
> > collection sections, but this patch doesn't address that.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@...gle.com>
> > ---
>
> > --- a/drivers/usb/core/hcd.c
> > +++ b/drivers/usb/core/hcd.c
> > @@ -1646,9 +1646,9 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
> >
> >       /* pass ownership to the completion handler */
> >       urb->status = status;
> > -     kcov_remote_start_usb((u64)urb->dev->bus->busnum);
> > +     kcov_remote_start_usb((u64)urb->dev->bus->busnum, KCOV_CONTEXT_SOFTIRQ);
> >       urb->complete(urb);
> > -     kcov_remote_stop();
> > +     kcov_remote_stop(KCOV_CONTEXT_SOFTIRQ);
>
> This isn't right.  __usb_hcd_giveback_urb() can execute in pretty much
> any context; its constraint is that interrupts must be disabled.

You're right, but here we constraint kcov to only collect coverage in
case __usb_hcd_giveback_urb() is  executed in softirq context. This is
what happens when we're fuzzing USB with the dummy driver, which is
the case we currently take care of. Whenever someone has a desire to
collect coverage in other contexts, it will need to be implemented
separately.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ